I am trying to split a string, and the string is (in MySQL):
"Accident (&); Travel;Car (&); Motorcycle."
You see, there are actually only two elements that I want to be in the array, [0] would be: "Accident & Travel, [1] would be the Car & Motorcycle
".
I used a delimiter (explode) for this one and imposed a delimiter with (";").
Now, the problem is, the symbol "&"
in MySQL is translated into (&);
(without the bracket), meaning now my string is split like they have 4 elements instead of 2:
"[0] = Accident &, [1] = Travel, [2] = Car &, [3] = Motorcycle.
"
How do I solve this ? I heard of preg_split before, but I'm not sure how to use it.
The php explode that I used:
"$string = "Accident (&); Travel; Car (&); Motorcycle";
$points = explode(";", $string);
?> <ul> <?php
for ($x = 0; $x < count($points); $x++) {
echo "<li>$points[$x]</li>";
}"