I have a string like this:
$values = "[121],[622],[872]";
I would like to convert this into an array, I would like each number in the square brackets to be an array item.
any suggestions how I can do this?
I have a string like this:
$values = "[121],[622],[872]";
I would like to convert this into an array, I would like each number in the square brackets to be an array item.
any suggestions how I can do this?
Seriously? Use explode()
$values = "[121],[622],[872]";
$values = str_replace(array("[", "]"), "", $values);
$values = explode(",", $values);
Or in a simpler way:
$array = explode("," ,str_replace(array("[", "]"), "", $values));
This gives values as:
Array
121
622
872
str_replace.