I'm trying to make this json string:
{phones:[{"numbers":12345},{"numbers":67890}]}
How can I achieve that from an exploded string?
$phones = '123456;7890';
$phones = explode(';', $phones);
I've tried using foreach
like this:
foreach ($phones as $phone) {
$array["numbers"] = $phone;
}
But it keep replacing the first key. and yes I read that PHP array can't have the same key on the same level of an array.