Arrays with subtags

From: Date: Sat, 17 Nov 2001 22:19:22 +0000
Subject: Arrays with subtags
Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-1938@lists.php.net to get a copy of this message
An cool addon: Try this: {insert name="foo" attributes_a="120" attributes_b="202" attributes_d_a="102" attributes_d_b="102"} function insert_foo($args) { $arrays = new arrays(); extract($arrays->string2array($args)); print_r($attributes); } <?PHP class arrays { var $divisor = "_"; function string2array($strings) { $returning = array(); while (list($varName,$varValue) = each($strings)) { $subs = split($this->divisor, $varName); if (count($subs) > 1) { for ($x = 0; $x < count($subs); $x++) { if ($x == 0) $anArray = "\$returning['$subs[$x]']"; else $anArray .= "['$subs[$x]']"; } $anArray .= " = '" . addslashes($varValue) . "'"; eval($anArray . ";"); } else { $returning[$varName] = $varValue; } } return $returning; } } ?> Atenciosamente, Roberto Berto' ---------------- roberto@berto.net eConsultor 0(XX)51 32270599 -> Horario preferencial: 13h - 20h 0(XX)51 91169628 -> Em outros horarios

« previous php.smarty.general (#1938) next »