RE: [PHP-WIN] in_array with an associative array... stuck
| From: | Asendorf, John | Date: | Tue, 04 Dec 2001 18:37:57 +0000 |
| Subject: | RE: [PHP-WIN] in_array with an associative array... stuck | ||
| Groups: | php.windows | ||
| Request: | Send a blank email to php-windows+get-10728@lists.php.net to get a copy of this message | ||
Nevermind... I figured it out by altering the inside_array pseudo function
---------------------
John Asendorf - jasendorf@lcounty.com
Web Applications Developer
http://www.lcounty.com - NEW FEATURES ADDED DAILY!
Licking County, Ohio, USA
740-349-3631
Nullum magnum ingenium sine mixtura dementiae fuit
> -----Original Message-----
> From: Asendorf, John [mailto:JAsendorf@lcounty.com]
> Sent: Tuesday, December 04, 2001 1:17 PM
> To: Php-Windows (E-mail)
> Subject: [PHP-WIN] in_array with an associative array... stuck
>
>
> I'm attempting to see if a variable exists in an associative
> array but I've
> come up empty after two hours... any help out there?
>
> I've already tried array_search and the psuedo functions
> inside_array and
> array_in_array from the user comments in the documentation
> but they all
> return false for what is an obvious match... I've also tried
> this with
> $CUST_CITY in "'s and out of them (e.g. in_array (
> "$CUST_CITY", $city_array
> ) and in_array ( $CUST_CITY, $city_array ) ) but I don't
> think I should
> need "'s around $CUST_CITY
>
>
>
> Pieces of the code that are relevent:
>
> $city_array = array (
> 'ALEXANDRIA' => '43001'
> ,'GLENFORD' => '43739'
> ,'GRANVILLE' => '43023'
> );
>
> $CUST_CITY = "GRANVILLE"; //this is actually retrieved from
> a database in
> the real code...
>
>
>
> if ( in_array ( $CUST_CITY , $city_array ) ) {
>
> if ( $debug ) { echo "<!-- FOUND $CUST_CITY IN
> ARRAY -->\n";
> }
> echo "<option value=\"NOT LISTED\">NOT
> LISTED</option>\n";
>
> //sift through city array and write city options
> foreach ( $city_array as $key => $value) {
>
> echo "<option ";
>
> if ( $CUST_CITY == $key) {
>
> echo "SELECTED";
> }
>
> echo "value=\"$key\">$key</option>\n";
>
> }
>
> echo " <input type=\"text\" name=\"ALT_CITY\"
> value=\"$CUST_CITY\">";
>
> }
>
> else {
>
> if ( $debug ) { echo "<!-- DID NOT FIND
> $CUST_CITY IN ARRAY
> 5-->\n"; }
> echo "<option SELECTED value=\"NOT LISTED\">NOT
> LISTED</option>\n";
>
> //sift through city array and write city options
> foreach ( $city_array as $key => $value) {
>
> echo "<option value=\"$key\">$key</option>\n";
>
> }
>
> echo " <input type=\"text\" name=\"ALT_CITY\"
> value=\"$CUST_CITY\">";
>
> }
>
>
> Thanks in advance.
>
> John
>
> ---------------------
> John Asendorf - jasendorf@lcounty.com
> Web Applications Developer
> http://www.lcounty.com - NEW FEATURES ADDED DAILY!
> Licking County, Ohio, USA
> 740-349-3631
> Nullum magnum ingenium sine mixtura dementiae fuit
>
>
> --
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-windows-unsubscribe@lists.php.net
> For additional commands, e-mail: php-windows-help@lists.php.net
> To contact the list administrators, e-mail:
> php-list-admin@lists.php.net
>