I have a string like this 2 661,38 € and I need to echo 661,38 but I can't reach to the solution
I have done the following code:
$connection=mysql_connect('localhost','root','****') or die(mysql_error());
mysql_select_db('DB',$connection) or die(mysql_error());
$sql = mysql_query("select distinct prod_price COL from TABLE") or die(mysql_error());
?>
<?php
while($row=mysql_fetch_object($sql)):?>
<?php
if(mysql_num_rows($sql)>0){
$number = $row->COL;
$temp=explode(' ',$number);
$number = preg_replace("/[^0-9]/", '', $temp[0])/100;
echo number_format($number, 2, ',', ' '). "<br />";
}
?>
<?php endwhile;?>
Can anyone please help me to remove that 2 from the first place ?
The solution I got is not helping me so I am putting the whole code to understand the situation I am got stuck...please see the code snippet...The above code is giving me the following Notice:
Notice: Undefined offset: 2 in /var/www/html/login/str.php on line 26 0,00
2) is required too. I think, the original string was2 661,38 €. Try to convert the original strings to UTF-8 with the following expression:CONVERT(CONVERT(YourColumn USING binary) USING utf8)(this probably returnsNULLif the original value could not be converted to UTF8, but if it is a valud UTF-8 sequence, then it will will be converted). Also plese be sure that the connection's and the PHP file's encoding is UTF-8 too.