PHP/Utility Function/parse str

Материал из Web эксперт
Перейти к: навигация, поиск

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>