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
Post a Comment