PHP/Utility Function/parse str

Материал из Web эксперт
Версия от 10:07, 26 мая 2010; Admin (обсуждение | вклад) (1 версия)
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Перейти к: навигация, поиск

Pass an array as the second parameter to parse_str( ), and it will put the variables into there

   <source lang="html4strict">

<?

   $array = array( );
   if (isset($array["foo"])) {
           print "Foo is {$array["foo"]}
"; } else { print "Foo is unset
"; } parse_str("foo=bar&bar=baz", $array); if (isset($array["foo"])) { print "Foo is {$array["foo"]}
"; } else { print "Foo is unset
"; }

?>

 </source>
   
  


void parse_str ( string str [, array &arr] ) take a query string and convert it to variables

   <source lang="html4strict">

<?

   if (isset($foo)) {
           print "Foo is $foo
"; } else { print "Foo is unset
"; } parse_str("foo=bar&bar=baz"); if (isset($foo)) { print "Foo is $foo
"; } else { print "Foo is unset
"; }

?>

 </source>