Re: [PHP] Arrays misbehaving!

2002-08-30 Thread Chris Wesley
On Fri, 30 Aug 2002, Cameron Thorne wrote: > I was hoping I could access by either name OR number, but apparently not. Just for kicks ... here's something pretty ugly (I'd never use it), but neat if you're interested (or somehow really have your heart set on using integers). There are probably

Re: [PHP] Arrays misbehaving!

2002-08-30 Thread Cameron Thorne
That does help, yes. So basically there is no way to access associative arrays using numerical indices? I was hoping I could access by either name OR number, but apparently not. Thanks! -- Cameron -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/u

Re: [PHP] Arrays misbehaving!

2002-08-30 Thread Chris Wesley
On Fri, 30 Aug 2002, Cameron Thorne wrote: > Can anyone explain why the following code operates the way it does in my > comments? Sure. > > $test = array ( 'a' => 'A', 'b' => 'B', 'c' => 'C'); An associative array, $test. > > if (array_key_exists(2, $test)) echo "It works by key number!"; /

[PHP] Arrays misbehaving!

2002-08-30 Thread Cameron Thorne
Can anyone explain why the following code operates the way it does in my comments? 'A', 'b' => 'B', 'c' => 'C'); if (array_key_exists(2, $test)) echo "It works by key number!"; // Does not work. if (array_key_exists('c', $test)) echo "It works by key name!"; // Works. print_r(array_keys($tes