Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

passing arrays in the url

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

Postby Joan Garnet » Sun Jan 26, 2003 1:33 pm

Try this one:
Code: Select all
//the output
if ($HTTP_GET_VARS){
   $i = 0;
   foreach($HTTP_GET_VARS as $v) {
       print "var$i = $v <br>";
      $i++;
   }
}else{
   //the link
   $a = array(1 => 'number_one', 2 => 'number_two', 3 => 'number_three');
   echo "<a href='".$php_self."?";//the begining of the html link
   //lets slice the array into variables
   $i = 0;
   foreach($a as $v) {
       print "var$i=$v";
      $i++;
      if ( $i != sizeof($a) ) { echo "&"; }
   }
   echo "'>pass the array</a>";//the end of the html link
}

It works just nice
:)
User avatar
Joan Garnet
Moderator
Moderator
 
Posts: 387
Joined: Sat Aug 03, 2002 2:56 am
Location: Mars

Return to PHP coding => General

Who is online

Users browsing this forum: Google [Bot] and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron