Re: Arrays

From: Date: Fri, 26 Oct 2001 15:41:42 +0000
Subject: Re: Arrays
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-72461@lists.php.net to get a copy of this message
Brad Hubbard wrote: > <?php > // Suck 'em in > > $site = array ( > "section1" => 007, > "section2" => 11, > "section3" => 57.5, > "section4" => 12, > "section10" => 1 > ); Okay, this answer the first part of my question. How would I go about checking variables against that array? I need to know if the contents of a variable $section exists in the array, and if so, if the contents of the accompanying variable $page is not negative, and less or equal to the INT value of that $section. In a different language I can write something that will return the index of $section in the array, then I can use that index value to fetch the INT afterwards: $array = {{"section1", 1},{"section2",4},{"section3",2}} if (idx = ($section in list_iassoc($array, 1))) => 1 being the first element // idx[1] = "section#" // idx[2] = INT if ($page > 0 && $page =< $array[idx][2]) etc. -- W | I haven't lost my mind; it's backed up on tape somewhere. +-------------------------------------------------------------------- Ashley M. Kirchner <mailto:ashley@pcraft.com> . 303.442.6410 x130 IT Director / SysAdmin / WebSmith . 800.441.3873 x130 Photo Craft Laboratories, Inc. . 3550 Arapahoe Ave. #6 http://www.pcraft.com ..... . . . Boulder, CO 80303, U.S.A.

« previous php.general (#72461) next »