add charset utf-8
add this code
echo '<meta charset="UTF-8">';
see the result I have tried
Question
I used a number below in my code:
$MyString = '068875581086163483346499660139294';
When i'm trying to split MyString into a same pieces for example: 06887558, 10861634 so on... using substr or str_split that gives me:
06887558, 10861634, 8​3346, 4996​6, 0139294
Someone explain why this happend?!?
The Code what I have tried
$MyNewString; $n = 8; // How many you want before seperation
$MyNewString = substr($MyString,0,$n);
$i = $n;
while ($i < strlen($MyString)) {
$MyNewString .= '-'; // Seperator Character
$MyNewString .= substr($MyString,$i,$n);
$i = $i + $n;
}
echo $MyNewString;
Solution
add charset utf-8
add this code
echo '<meta charset="UTF-8">';
see the result I have tried
OTHER TIPS
$new_string = implode(', ', str_split($n, 8));
echo $new_string;
If you're getting funny characters in the result, then they must have been in the original string. substr
and str_split
don't add anything.