I have string like this 1-male,2-female
I want to make this as array like following
array(
1 => male,
2 => female
);
i can make this by using foreach Ex:
$str1 = '1-male,2-female';
$outPutArr = array();
$arr1 = explode(',' $str1);
foreach($arr1 as $str2){
$arr2 = explode('-', $str2);
$outPutArr[$arr2[0]] = $arr2[1];
}
Is there any other short cut to do this?