Re: [PHP] Recursive array_push?

2006-01-26 Thread Robin Vickery
On 1/26/06, Kim Christensen [EMAIL PROTECTED] wrote: I would really like PHP to have a function of building expressions with strings, and then execute them through a function - but that's just me it seems :-) You mean like create_function() ? -robin

Re: [PHP] Recursive array_push?

2006-01-26 Thread David Grant
Kim, May the hack-o-rama commence: ?php $str = [layer1][layer2][layer3][layer4]; $parts = explode(][, substr($str, 1, -1)); $text = ; foreach ($parts as $part) { $text .= 'a:1:{s:' . strlen($part) . ':' . $part . ';'; } $text .= 'b:1;' . str_repeat('}', count($parts));

Re: [PHP] Recursive array_push?

2006-01-26 Thread Jochem Maas
Kim Christensen wrote: Has anyone out there stumbled over the issue of making multi-dimensional arrays out of bracket-separated strings? In a less fuzzy way of putting it: $str = [layer1][layer2][layer3][layer4] would become $str_array = Array( [layer1] = Array( [layer2] = Array( [layer3] =

Re: [PHP] Recursive array_push?

2006-01-26 Thread David Grant
Kim, After some contemplation (and slightly less crack): ?php $str = [layer1][layer2][layer3][layer4]; $parts = array_reverse(explode(][, substr($str, 1, -1))); $array = FOO; foreach ($parts as $part) { $array = array($part = $array); } print_r($array); ? Array ( [layer1] = Array

Re: [PHP] Recursive array_push?

2006-01-26 Thread Richard Lynch
On Thu, January 26, 2006 2:50 am, Kim Christensen wrote: Has anyone out there stumbled over the issue of making multi-dimensional arrays out of bracket-separated strings? In a less fuzzy way of putting it: $str = [layer1][layer2][layer3][layer4] would become $str_array = Array( [layer1] =