[PHP] preg_match

2007-02-06 Thread James Lockie
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

2007-02-06 Thread James Lockie

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

2007-05-17 Thread James Lockie

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

2007-05-18 Thread James Lockie

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

2007-05-23 Thread James Lockie

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

2007-05-23 Thread James Lockie

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