php - How to use a wildcard in an if statement? -


would possible use wildcard in if statement this?

if(trim($line) != $delete) 

full code:

 $delete = "*totalwar";  $data = file("../oneos/applist.txt");  $out = array();   foreach($data $line) {      if(trim($line) != $delete) {          $out[] = $line;      }  }   $fp = fopen("./foo.txt", "w+");  flock($fp, lock_ex);  foreach($out $line) {      fwrite($fp, $line);  }  flock($fp, lock_un);  fclose($fp);   

i complete php noob, php way see project working. need user able delete line in text file, no matter infront of text enter. example, if user enters delete totalwar , text file looks this: set app24=totalwar, need script delete entire line.

you can use fnmatch() this

fnmatch() checks if passed string match given shell wildcard pattern.

for more info read http://php.net/fnmatch


Comments

Popular posts from this blog

javascript - Thinglink image not visible until browser resize -

firebird - Error "invalid transaction handle (expecting explicit transaction start)" executing script from Delphi -

mongodb - How to keep track of users making Stripe Payments -