Re: Recursive array_push?
| From: | David Grant | Date: | Thu, 26 Jan 2006 09:35:33 +0000 |
| Subject: | Re: Recursive array_push? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-229299@lists.php.net to get a copy of this message | ||
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));
print_r(unserialize($text));
?>
It works, but I'm not proud. :P
David
--
David Grant
http://www.grant.org.uk/