Re: [PHP4BETA] re:array navigation

From: Date: Tue, 13 Jun 2000 02:19:32 +0000
Subject: Re: [PHP4BETA] re:array navigation
References: 1  Groups: php.version4 
Request: Send a blank email to php-version4+get-16269@lists.php.net to get a copy of this message
Dan wrote: > Isolate your file name and use associative arrays for your values. > > $Next[ "zero" ] = "one.htm"; > $Next[ "one" ] = "two.htm"; > > Then use $Next[ $filename ] to get the value. > > Here's a function to isolate the filename (no extension), called using the > "macro" for the filename (which included the path) > > $filename = JustFileName( __FILE__ ); > > function JustFileName( $pathAndFile ) > { > $basename = basename( $pathAndFile ); > > $pos = strrpos($basename, "." ); > > if ($pos) > return substr( $basename, 0, $pos ); > else > return $basename; > } Cool thanks, just what I wanted, for those of you following this thread just remember to call the constant __File__ inside the file you want to retrieve the filename from, don't put this in a include file as it won't work as I just discovered. Joseph Blythe -- BoldFX / Binary Logic 257 Churchill Road Prospect South Australia 5082 Ph: (08) 8342 0022 Fax: (08) 8342 0155 mailto: joseph.blythe@binarylogic.com.au

« previous php.version4 (#16269) next »