I try to do a switch on a multidimensional array :
$types = array (
'type1' => array('value1', 'value2'),
'type2' => array('value3', 'value4');
...
);
$prefix = substr($number, 0, 4);
foreach ($types as $key => $values) {
switch ($prefix) {
case 'type1' :
$type = 'TYPE1';
break;
case 'type2' :
$type = 'TYPE2';
break;
...
}
}
Where the $prefix is equal to a value in $types array.
But it didn't works. I guess i'm close to the solution, but can't find it (googled gave me nothing more). Thanks (:
I'm not sure to understand.
If $prefix
= 'value1'
or 'value2'
or 'value3'
.... you can try something like this:
foreach ($types as $key => $values) {
if (in_array($prefix, $values) )
$type = strtoupper($key);
}
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments