RE: Array Search Not Working?
| From: | Alice Wei | Date: | Wed, 10 Mar 2010 17:21:57 +0000 |
| Subject: | RE: Array Search Not Working? | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-302672@lists.php.net to get a copy of this message | ||
>
> I'm still a little foggy on what you're doing, but doing, but does this
> help?
>
> $from = explode("-", $from);
> $state_colors = explode("-", $state_colors);
> $change = explode("-", $change);
>
> $old = array_combine($from, $state_colors);
> $new = array_combine($from, $change);
>
> //show all values
> foreach($old as $key => $val) {
> echo "{$key} old={$old[$key]} new={$new[$key]}<br />\n";
> }
>
> //lookup a particular value
> $test = "Muskogee, OK";
> echo "TEST={$test} old={$old[$test]} new={$new[$test]}<br />\n";
>
Well, here is the weird part. put up the last 3 lines of your code here into mine, and here is the
output:TEST=Muskogee, OK old= new=
I am starting to wonder if there are other things hidden inside the "values" that seems
like that the values of the new array (the state and counties part) are the same as the original
when I tried to do the comparison. This is what I mean by the fact that my array_search does not
work, and all I am trying to do is to find the index, so I can do stateColors[$index] later on and
color my map.
Have I done something wrong here that causes the code you provided not to spit out anything here?
This is what I have:
$from = explode("-", $from);
$state_colors= explode("-", $state_colors);
$change = explode("-",$change);
$new_array = array_combine($from,$change);
asort($new_array);
foreach ($new_array as $key => $value) echo $key . " is " . $value . " miles
away<br />";
Thanks.
Alice
_________________________________________________________________
Hotmail: Trusted email with Microsoft’s powerful SPAM protection.
http://clk.atdmt.com/GBL/go/201469226/direct/01/