I am trying to fetch some data from the MySQL database to my view page using PHP. All is working fine but While I have print price value on my page it will display like:
<?php $myPriceString = 1,2569.50/nos echo $myPriceString ?>
Output: 12569.00/nos
I need to display the price value not the “/nos” part. How can I get the string before the symbol ‘/’ in PHP?
I am trying to apply the (integer) function but it does not work correctly.
My Code:
If you want to get string before the symbol ‘/’ in PHP, apply this code
<?php $myPriceString = "1,2569.50/nos"; echo (integer)$myPriceString ?>
Output: 1
Question and answer is powered by AnsPress.io