Reputation: 2499
Now this should be simple, sure I'm doing smt stupid here.
I'm trying to divide a string made of a number and currency, into an array with one cell having the number, and another the currency. Not rocket science, right?
My code is smt as follows:
var_dump($valueWithCurrency);
var_dump(explode(" ", $valueWithCurrency));
Now the result of var_dump are as follows:
string(11) "-50,00 kr."
and
array(1) {
[0] =>
string(11) "-50,00 kr."
}
I tried a million different variations, nothing working. My question is, why the simple explode isn't splitting the string by spaces??
Upvotes: 0
Views: 252
Reputation: 369
You probably have a non-breaking space between the number and the currency (as it should be). You may solve your problem by using the hexadecimal coding of non-breaking space:
explode("\xc2\xa0", $valueWithCurrency)
Upvotes: 3