-1


Iam a beginner of PHP .
My question is soo small.

Suppose , my current value is 250 Taka.
or BDT 250 /-

How can i show only price : 250 ?

My code :

$maxprice= "250 Taka.";
<td style="width: 20%;"><?php echo $maxprice; ?></td>

Thanks

Nirab
  • 61
  • 3
  • 10

1 Answers1

0

You can use preg_replace and replace everything not a digit

$maxprice = preg_replace('/[^\d]+/', '', $maxprice);

For Example

The Regx is pretty simple:

  • [^...]+ anything not in character set One or more times
  • \d any digit 0-9

So it replaces anything that is not 0-9.

Enjoy

ArtisticPhoenix
  • 21,464
  • 2
  • 24
  • 38