I have an array that I pull that looks like this:
[157966745,275000353,43192565,305328212]...
How do I go about taking that "string" and converting it to a PHP array which I can then manipulate.
I have an array that I pull that looks like this:
[157966745,275000353,43192565,305328212]...
How do I go about taking that "string" and converting it to a PHP array which I can then manipulate.
This looks like JSON, so you can use json_decode:
$str = "[157966745,275000353,43192565,305328212]";
$data = json_decode($str);
json_decode() will produce an array of integers whereas explode() will create an array of strings.PHP explode is built just for this.
$result = explode(',', $input)
The answer by @Felix Kling is much more appropriate given the context of the question.
$new_string = preg_replace('/([\[|\]])/', '', $strarr);
$new_array = explode(',', $new_string);`