|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2015-01-12 19:08 UTC] requinix@php.net
-Status: Open
+Status: Not a bug
[2015-01-12 19:08 UTC] requinix@php.net
[2015-01-13 12:43 UTC] andrecamargotti at gmail dot com
[2015-01-13 14:20 UTC] anon at anon dot anon
[2015-01-13 14:27 UTC] andrecamargotti at gmail dot com
|
|||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 06 13:00:01 2026 UTC |
Description: ------------ sorry for the english i wrote this script $lines = file( $this->file, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES ); foreach ( $lines as $line ) { $numline = $numline+1; if( preg_match( '/new\s?[a-z0-9]+\s?/i', $line)) { echo "ok $numline";} } } and $this-file refers to an file where i wrote this: new CR_a123) the script print in the screen ok followed by number of the line (wrong) if i change the script to this $lines = file( $this->file, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES ); foreach ( $lines as $line ) { $numline = $numline+1; if( preg_match( '/new\s?[a-z0-9]+\s?\)/i', $line)) { echo "ok $numline";} } } the script don't print anything (right) thanks for the help the first script was worng because the expression have an underscore, and in script i especified that can be only numbers and letters. the second script is correct because the script cannot output ok. i change the second script to: $lines = file( $this->file, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES ); foreach ( $lines as $line ) { $numline = $numline+1; if( preg_match( '/new\s?[a-z0-9_]+\s?\)/i', $line)) { echo "ok $numline";} } } the third script prints ok (right) now i have put underscore in the regular expression, so now the script can print ok.