Php preg_split does not recognize spaces

I copy and paste football games from Betfair, for example. "Bournemouth v Tottenham" and it is stored in a MySQL database. However, when I try:

preg_split('/\s+/', $row['match']); 

As suggested here earlier, it does not break into the first space (my final goal would be something like '/ \ s [v] \ s /'). When I manually rewrite the field in the database as "v", it then decomposes it correctly. What can it be with this symbol, since it looks like space in both the browser and PHPMyAdmin, but does not parse it? I tried but no luck. Example line:

Barcelona v Manchester City - Wednesday 19:45

with this parsing: http://pasteall.org/pic/show.php?id=107841 It does not split the string to "Man City", not "v". The first one works when I manually replaced the problematic characters with spaces in the database

+1
string php mysql parsing preg-split
Oct 19 '16 at 12:19
source share
1 answer

Although the database talks about UTF8 characters, when PHP asks what it says latin1. The solution was:

 mysqli_set_charset($dbc, "utf8"); 
+1
Oct 19 '16 at 16:31
source share



All Articles