codepad
[
create a new paste
]
login
|
about
Language:
C
C++
D
Haskell
Lua
OCaml
PHP
Perl
Plain Text
Python
Ruby
Scheme
Tcl
<?php # -------------------------------------------- [ dataxchg.php (fragment) function param2Hidden ($hash_this) { $str_result = ''; foreach ($hash_this as $str_thisname => $str_thisvalue) { if (is_array($str_thisvalue)) { foreach ($str_thisvalue as $str_thiselement) { $str_result .= "\t<input type=\"hidden\" \"name=\"$str_thisname\[\]\" value=\"$str_thiselement\" /> \n"; } } else { $str_result .= "\t<input type=\"hidden\" \"name=\"$str_thisname\" value=\"$str_thisvalue\" /> \n"; } } return $str_result; } function ah2List ($ah_this, $str_id='', $str_name='data', $str_class='') { $str_result = ''; $str_result .= "<ol "; if ($str_id) $str_result .= 'id="'.$str_id.'" '; $str_result .= 'name="'.$str_name.'" '; if ($str_class) $str_result .= 'class="'.$str_class.'" '; $str_result .= "> \n"; foreach ($ah_this as $hash_this) { $str_thisclass = ($hash_this["class"]) ? 'class="'.$hash_this["class"].'"' : ''; $str_thislink = ($hash_this["link"]) ? $hash_this["link"] : ''; $str_thisname = $hash_this["name"]; $str_thisicon = ($hash_this["icon"]) ? $hash_this["icon"] : ''; $str_result .= "\t<li $str_thisclass>"; if ($str_thislink) $str_result .= "<a href=\"$str_thislink\">"; if ($str_thisicon) $str_result .= "<img src=\"$str_thisicon\" class=\"icon\" alt=\"$str_thisname\" />"; $str_result .= $str_thisname; if ($str_thislink) $str_result .= "</a>"; $str_result .= "</li> \n"; } $str_result .= "</ol> \n"; return $str_result; } # -------------------------------------------- [ auxiliary $hash_imidazopyridine = array("q1"=>"Alpidem", "q2"=>"Saripidem", "q3"=>"Zolpidem"); $ah_subd = array( array ("link"=>'chon.php', "name"=>'Chondrostei'), array ("class"=>'teleostei', "link"=>'neopt.php', "name"=>'Neopterygii'), array ("class"=>'lungfish', id=>'', "link"=>'coel.php', "name"=>'Coelacanths'), array ("class"=>'amniota', "name"=>'Tetrapods'), ); print param2Hidden($hash_imidazopyridine)."\n\n"; print ah2List($ah_subd, 'fish', 'Osteichthyes', 'testdata')."\n\n"; ?>
Private
[
?
]
Run code
Submit