[PHP] preg_match
I am trying to use this code to display a button at the root but it always displays the button. :-( if (! (preg_match( "/$\/index.php/", $_SERVER['PHP_SELF'] ))) { # display a button -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] preg_match
Myron Turner wrote: James Lockie wrote: I am trying to use this code to display a button at the root but it always displays the button. :-( if (! (preg_match( "/$\/index.php/", $_SERVER['PHP_SELF'] ))) { # display a button You got the end-of-string character ($) in the wrong place: if (! (preg_match( "/\/index.php$/", $_SERVER['PHP_SELF'] ))) { Richard Lynch wrote: On Tue, February 6, 2007 7:46 pm, James Lockie wrote: I am trying to use this code to display a button at the root but it always displays the button. :-( if (! (preg_match( "/$\/index.php/", $_SERVER['PHP_SELF'] ))) { Without any "modifier", $ matches the END of the string. I wanted this. :-( Thanks. if (! (preg_match( "/^\/index.php/", $_SERVER['PHP_SELF'] ))) { # display a button -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] showing source
This almost works but all my < and > are replaced with "". // open this file to show the source if (($fh = fopen( __FILE__, 'r' )) === FALSE){ die ('Failed to open source file (' . $_FILE_ . ') for reading!'); } else { $tags = array( "<", ">" ); $safe_tags = array( "\\<", "\\>" ); print "\n"; // read the file line by line while (! feof( $fh )) { $currentLine = fgets( $fh, 255 ); $noTags = str_replace( $tags, $safeTags, $currentLine ); print $noTags; } fclose( $fh ); print "\n"; } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: showing source
M.Sokolewicz wrote: Why don't you use: highlight_file(__FILE__) ? I didn't know about that. Awesome, thanks. :-) I used the highlight_num from the comments to show line numbers. :-) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] help with multi dimensional arrays
I get a syntax error on strlen. $newTypes = array(); $newTypes[0] = array(); $newTypes[0][0] = "Starting with" $newTypes[0][1] = strlen( $newTypes[0][0] ); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] help with multi dimensional arrays
Paul Novitski wrote: Looks like you are missing a comma on line 3. James Lockie wrote: I get a syntax error on strlen. $newTypes = array(); $newTypes[0] = array(); $newTypes[0][0] = "Starting with" $newTypes[0][1] = strlen( $newTypes[0][0] ); Missing semicolon; Paul Argh, that is the worst error. :-( The error messages in PHP suck. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php