If you have a multidimensional array, such as follows:
$array = array(
'name' => 'user',
'values' => 'one, two, three',
'params' => array('three');
);
How can you split 'values' key so it then becomes an array on its own?
ie
$array = array(
'name' => 'user',
'values' => array('one', 'two', 'three'),
'params' => array('three');
);
$array['values'] = explode(', ', $array['values']);
If you wish to run this check on all the fields and not just the values one:
foreach($array as &$value)
{
if (!is_array($value))
{
$value = explode(', ', $value);
}
}
unset($value);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.