PDA

View Full Version : complex if() else() (well for me its)



sWo0p
June 11th, 2005, 05:24 AM
hi, :kommie:pians

wel im strugeling a bit here.. im not a genius in php but im managing so far... problem is i have a real tricky if else to figure out now... can anyone help

ok i have to link (imdb and moviemeter) the script needs to figure out if my link is to be used with a imdb or with moviemeter and els its not to link at all.... hoop u understand what im going for.. :S:S

$pieces[10] reads tabel 10 from a *.cvs file the data from that file is eighter TT0... or 1234 or <nothing> how am i gonne do this with if/else? :h: :ear:

imported_ramie
June 11th, 2005, 05:39 AM
ok, first you need to search for a pattern in the string, if it matchs a pattern then it does something, of it dosent then its not a valid link.....



$imdb_link ="/imdb/";
$moviemeter_link ="/moviemeter/";

if(preg_match($imdb_link, $the_link_your_searching) {
// do something
} elseif (preg_match($moviemeter_link, $the_link_your_searching) {
// do something different
} else {
// the link was not found
}


http://uk.php.net/preg_match

Ray.