Kill Joy wrote:
Quote:
Hi all.
>
I have a file that stats with
___________________________________
/* Vim-generated file */
//Generated settings file for Vim project.
...
.......
___________________________________
>
I open it with:
>
___________________________________
$log = file("project_vim.js");
>
foreach($log as $value){
if(eregi("vim", $value)) {
echo $value."";
}
}
___________________________________
>
>
But I match nothing
>
Why?
>
Many thanks.
>
Cheers.
>
Gius.
First, off, when using regex, don't use POSIX (ereg*), they're slower
and less powerful than PCRE.
Also, from the looks of your code, you don't even need regex:
if ( strstr($value, 'vim') )
echo $value;
If the substring 'vim' exists within $value, the strstr returns true.
It's also case sensitive. If you can ignore case by using stristr,
instead.
Have a look through the String Functions portion of the PHP manual:
<URL:http://php.net/manual/en/ref.strings.php>
Curtis (
http://dyersweb.com/)