note 80020 deleted from ref.array by felipe
| From: | felipe@php.net | Date: | Sun, 30 Dec 2007 19:32:08 +0000 |
| Subject: | note 80020 deleted from ref.array by felipe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-134539@lists.php.net to get a copy of this message | ||
Note Submitter: geo at avelgold dot ru
----
<?php
$array['weight']='weight';
$array['price']=array('value1'=>'v1','value2'=>'v2');
$array['count']='count';
print get_value($array, 'price.value2');
function get_value($array, $st)
{
$stroka=$st;
$st=explode('.',$st);
if (count($st)>1 and is_array($array))
{
foreach ($st as $value)
{
if (isset($array[$value]))
{
$stroka=substr($stroka,strpos($stroka,'.')+1);
return get_value($array[$value],$stroka);
break;
}
}
}
if (count($st)==1 and is_array($array)==1) return $array[$st[0]];
}
?>