F
F
funkydance2018-11-20 18:17:20
PHP
funkydance, 2018-11-20 18:17:20

How to parse an array into a variable?

The table has a field with data like [17650,17776,17777]
How can I use php to get each value from [] without a comma into a variable?
So that later the cycle could display each value separately.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
E
Eugene, 2018-11-20
@funkydance

$string = '[17650,17776,17777]';

preg_match_all('/\d+/', $string, $matches);

var_dump($matches[0]);

N
nozzy, 2018-11-20
@nozzy

$string = '[17650,17776,17777]';
$array = eval("return " . $string . ";");
var_dump($array[0]);

B
Beliyadm, 2018-11-25
@beliyadm

explode ?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question