With regular expressions, how do I match anything not having:
.php
exactly? I tried:
^[^\.php]+$
But this seems to be match not . or p or h or p.
With regular expressions, how do I match anything not having:
.php
exactly? I tried:
^[^\.php]+$
But this seems to be match not . or p or h or p.
 
    
    Use negative lookahead in your regex to check whether there is any .php is available or not.
$text = 'some php text';
if(preg_match("/^(?!.*\.php)(.*)$/", $text, $m)){
    print_r($m[1]);
}
^ is the beginning of the string.
(?!.*\.php) is checking if there is no .php in upfront.
And (.*)$ is capturing everything till the end.
