Re: [PHP] Extracting Variables From URL
I think you should try: http://php.net/parse_url greets Zoltán Németh 2007. 05. 16, szerda keltezéssel 19.40-kor CK ezt írta: > Hi All, > > The following code works just fine for outputting links from an > array. The next goal, is parsing the $thisPage variable from the URL > (http://bushidodeep.com/contact.html/) so as $thisPage=strtolower("contact");?>, this variable could also be > assigned to the $links[] $key. > > Moving to a dynamic link generator class, what PHP function(s) could > be used to parse the URL? > > > "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";> > http://www.w3.org/1999/xhtml";> > > > Generate Links > > > > > > $links=array("Home","Work","Contact"); > $count =0; > echo " \n"; > foreach($links as $key){ > if(strtolower($key)!= $thisPage){ > echo (" $key\">$key\n"); > $count ++; > }else{ > echo ("$key"); > } > } > echo " \n"; > > > /*prints key as tabindex.. > $links=array("home","work","contact"); > $count =0; > echo " \n"; > foreach($links as $key){ > echo (" $key\">$key\n"); > $count ++; > } > echo " \n"; > */ > > ?> > > > > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Extracting Variables From URL
http://www.php.net/reserved.variables use $_SERVER['PHP_SELF'] or $_SERVER['REQUEST_URI'] just parse its value to get what you needed. hth, John On 5/17/07, CK <[EMAIL PROTECTED]> wrote: Hi All, The following code works just fine for outputting links from an array. The next goal, is parsing the $thisPage variable from the URL (http://bushidodeep.com/contact.html/) so as , this variable could also be assigned to the $links[] $key. Moving to a dynamic link generator class, what PHP function(s) could be used to parse the URL? http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";> http://www.w3.org/1999/xhtml";> Generate Links \n"; foreach($links as $key){ if(strtolower($key)!= $thisPage){ echo ("$key\n"); $count ++; }else{ echo ("$key"); } } echo " \n"; /*prints key as tabindex.. $links=array("home","work","contact"); $count =0; echo " \n"; foreach($links as $key){ echo ("$key\n"); $count ++; } echo " \n"; */ ?> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- GMail Rocks!!!
RE: [PHP] Extracting Variables
> echo "i = $i"; > for($c=1;$c<=$i;$c++){ > echo "team_number $team_number_$c"; > echo "sub1_$c = $sub1_$c"; > echo "sub2_$c = $sub2_$c"; > echo "sub3_$c = $sub3_$c"; > echo "sub4_$c = $sub4_$c"; > echo "sub5_$c = $sub5_$c"; > } > } Perhaps this: Echo "sub1_$c = $sub1_$c[$c]"; -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Extracting Variables
> -Original Message- > From: Steve Buehler [mailto:[EMAIL PROTECTED]] > Sent: 13 June 2002 15:54 > > I hope that someone will be kind enough to help me on this. > I want to do something like the following, but it does not work: > testinput(); > function testinput(){ > GLOBAL $HTTP_POST_VARS; > extract($HTTP_POST_VARS); > echo "i = $i"; > for($c=1;$c<=$i;$c++){ > echo "team_number $team_number_$c"; > echo "sub1_$c = $sub1_$c"; > echo "sub2_$c = $sub2_$c"; > echo "sub3_$c = $sub3_$c"; > echo "sub4_$c = $sub4_$c"; > echo "sub5_$c = $sub5_$c"; > } > } I don't think you can do this directly in a single string (at least, I haven't been able to!). However, either of the following formats should work for you: echo "sub1_$c = " . ${"sub1_$c"} . ''; echo "sub1_$c = " . ${'sub1_'.$c} . ''; But -- erm -- can I just ask why you're not using arrays, which might make life somewhat easier?! Cheers! Mike - Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning & Information Services, JG125, James Graham Building, Leeds Metropolitan University, Beckett Park, LEEDS, LS6 3QS, United Kingdom Email: [EMAIL PROTECTED] Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php