I have an array
$arr=('cat'=>'1:2:3', 'dog'=>'2:4:5');
i want to split this array and use key for new array name
ex. $cat=array('1','2','3')
$dog=array('2','4','5')
Thanks for answer and suggestion
how can split associative array and create new array?
Moderator: General Moderators
-
destiny_cores
- Forum Newbie
- Posts: 8
- Joined: Fri Mar 17, 2006 9:05 am
If I understand you correctly... this should do it.
Code: Select all
$arr= array('cat' => '1:2:3', 'dog' => '2:4:5');
foreach($arr as $key => $val){
${$key} = explode(":", $val);
}