Forum Moderators: coopster
I need to check one variable for a match, with another variable, WITH a wildcard....
To give u an idea of whats going on....
// ///////////// FUN STARTS HERE ///////////////
//get and set variables
$query = $_GET['query'];
$numba = 1;
//go and get the last created file number, sets $count
include ("count.txt");
//start the loop
while ($numba =< $count){
include ("$numba.txt");
// //////////// HERES WHERE IM LOST...
//i dont know how to code this.....
if *$query* = $variable1 then echo "$variable1";
if *$query* = $variable2 then echo "$variable2";
if *$query* = $variable3 then echo "$variable3";
//for example if $query happens to be "dollar"
//and $variable1 is "million dollar man"
//and $variable2 is "can i borrow 3 dollars?"
//and $variable3 is "no, im broke"
// it in turn, would echo $variable1 and $variable2
// /////////// HERES WHERE IM FOUND AGAIN...
//adds 1, so the NEXT text file will be included when the loop restarts
$numba++};
// /////////// END FUN HERE //////////////////
how do i make it check for a match with a wildcard before and after the $query ?
if(strpos($variable1, $query)!== false) echo $variable1;
You need to put!== not just!= because strpos returns 0 if a string is found at 1st place ("Dollars are cheap") strpos -> 0. ("No pounds here") strpos -> false.
BTW no need to place " in echo $variable; because $variable is already a string, or will be transformed to if necessary.
Best regards
Michal Cibor