note 68747 added to language.references
| From: | gunter dot sammet at gmail dot com | Date: | Wed, 09 Aug 2006 08:23:45 +0000 |
| Subject: | note 68747 added to language.references | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-115723@lists.php.net to get a copy of this message | ||
I tried to create an array with n depth using a recursive function passing array references around.
So far I haven't had much luck and I couldn't find anything on the web. So I ended up
using eval() and it seems to work well:
<?php
foreach(array_keys($this->quantity_array) AS $key){
if($this->quantity_array[$key] > 0){
$combinations = explode('-', $key);
$eval_string = '$eval_array';
foreach(array_keys($combinations) AS $key2){
$option_key_value = explode('_', $combinations[$key2]);
$eval_string .=
'['.$option_key_value[0].']['.$option_key_value[1].']';
}
$eval_string .= ' = '.$this->quantity_array[$key].';';
eval($eval_string);
}
}
?>
This produces an n dimensional array that will be available in the $eval_array variable. Hope it
helps somebody!
----
Server IP: 66.163.161.117
Probable Submitter: 137.186.217.82
----
X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER
autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/language.references.php
Edit -- https://master.php.net/note/edit/68747
Del: integrated -- https://master.php.net/note/delete/68747/integrated
Del: useless -- https://master.php.net/note/delete/68747/useless
Del: bad code -- https://master.php.net/note/delete/68747/bad+code
Del: spam -- https://master.php.net/note/delete/68747/spam
Del: non-english -- https://master.php.net/note/delete/68747/non-english
Del: in docs -- https://master.php.net/note/delete/68747/in+docs
Del: other reasons-- https://master.php.net/note/delete/68747
Reject -- https://master.php.net/note/reject/68747
Search -- https://master.php.net/manage/user-notes.php