|
|
||||||
|
||||||
| Index Link To US Private Messages Archive FAQ RSS | ||||||
| Programming Programmers can seek advice or just show off their creations inside this forum. |
Share Thread: & Tags
|
||||||
|
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
hi, i have a question on how to check strings in PHP.
Situation: when i'm at the url www.mydomain.com/fitness i want to show the image "personal_trainer.jpg" see code: <?php $img = ""; // variable for the name of the image switch ($_SERVER['REQUEST_URI']) // requesting the url of the page i'm at { case "/fitness/": $img = "personal_trainer.jpg"; break; ... } ?> That works fine. Now, i also want to show that same image for variations of this url, like /fitness/?biz=24 or /fitness/?biz=1542 can anyone adjust the above code to make this happen? thanks. |
|
||||
|
My bolding
Isn't that simple conditional programming?
__________________
Mini Network:: Financial information at your fingertips Learn object oriented programming where it started Last edited by kgun; 11-06-2009 at 08:00 AM. |
|
|||
|
Conditional programming. yes.
Simple. haha.not for me. i suppose i should use the PHP function "stripos" to get the job done. if anyone could just feed the solution right into my mouth.. |
|
|||
|
Although, Wige is correct that ereg would be a great method for doing this, if you aren't familiar with regular expressions, they tend to get tedious.
Keeping with Wige's if statement, why not just use something like strpos? It is easy to understand and easy to use and make updates to. Like Wige says case statements have their purpose and are highly versatile, I believe regular expressions over complicate otherwise simple solutions. PHP Code:
Please note the !== , the double equal sign is proper format for this specific call. PHP: strpos - Manual Quote:
|
|
||||
|
...and if you don't use them you won't get familiar with them, which IS tedious. I'm with wige on this one. I like regular expressions.
__________________
There are 10 types of people in this world: those who understand binary and those who don't. |
![]() |
|
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| An Easy CSS DIV question | spenland | Graphics & Design Discussion Forum | 3 | 05-24-2006 04:15 PM |
| B2B Or Not B2B, That’s An Easy Question | dutter | Insider Reports | 1 | 08-18-2005 08:02 PM |
| Just read the SEO is BS string,.. | mogrady | Search Engine Optimization Forum | 3 | 11-23-2004 05:31 PM |
| Quick, easy question... I think. | mlevenhagen | Search Engine Optimization Forum | 4 | 10-31-2004 06:06 PM |
| Easy question for the experts | tenaki | Graphics & Design Discussion Forum | 7 | 11-28-2003 03:43 PM |
|
WebProWorld |
Advertise |
Contact Us |
About |
Forum Rules |
MVP's |
Archive |
Newsletter Archive |
Top |
WebProNews
WebProWorld is an iEntry, Inc. ® site - © 2009 All Rights Reserved Privacy Policy and Legal iEntry, Inc. 2549 Richmond Rd. Lexington KY, 40509 |