/    Sign up×
Community /Pin to ProfileBookmark

I have an array like this:

[code=php]
$temp_stores[$key] = array(
name=>$D->results[LOLCN_NAME][$i]
,addr1=>$D->results[LOLCN_ADDRESS][$i]
,city=>$D->results[LOLCN_CITY][$i]
,state=>$D->results[LOLCN_STATE][$i]
,zip=>$D->results[LOLCN_ZIP][$i]
,phone_fe=>$fep
,phone_ph=>$rxp
,phone_phf=>$rxpf
,distance=>$store_numbers[$key][distance]
,convenience_foods=>$D->results[LOLCN_FOOD_ATTR][$i]
,rite_express=>$D->results[LOLCN_EXPRESS_ATTR][$i]
,one_hour_photo=>$D->results[LOLCN_PHOTO_ATTR][$i]
,ra_24_hour=>$D->results[LOLCN_TWENTYFOUR_ATTR][$i]
,drive_thru_rx=>$D->results[LOLCN_DRIVETHRU_ATTR][$i]
,rite_rewards=>$D->results[LOLCN_RITEREWARDS_ATTR][$i]
,gnc=>$D->results[LOLCN_GNC_ATTR][$i]
,western_union=>$D->results[LOLCN_WESTUNION_ATTR][$i]
,hours_fe_mon=>$D->results[LOLCN_FE_HRS_MON][$i]
,hours_fe_tue=>$D->results[LOLCN_FE_HRS_TUE][$i]
,hours_fe_wed=>$D->results[LOLCN_FE_HRS_WED][$i]
,hours_fe_thu=>$D->results[LOLCN_FE_HRS_THU][$i]
,hours_fe_fri=>$D->results[LOLCN_FE_HRS_FRI][$i]
,hours_fe_sat=>$D->results[LOLCN_FE_HRS_SAT][$i]
,hours_fe_sun=>$D->results[LOLCN_FE_HRS_SUN][$i]
,hours_rx_mon=>$D->results[LOLCN_RX_HRS_MON][$i]
,hours_rx_tue=>$D->results[LOLCN_RX_HRS_TUE][$i]
,hours_rx_wed=>$D->results[LOLCN_RX_HRS_WED][$i]
,hours_rx_thu=>$D->results[LOLCN_RX_HRS_THU][$i]
,hours_rx_fri=>$D->results[LOLCN_RX_HRS_FRI][$i]
,hours_rx_sat=>$D->results[LOLCN_RX_HRS_SAT][$i]
,hours_rx_sun=>$D->results[LOLCN_RX_HRS_SUN][$i]
,store_date_open=>$D->results[MY_LOLCN_PROJ_OPEN_DTE][$i]
,store_date_relo=>$D->results[MY_LOLCN_RELOCN_DTE][$i]
,store_date_reopen=>$D->results[MY_LOLCN_REOPEN_DTE][$i]
,picture_maker=>$D->results[PICTURE_MAKER][$i]
,photo_ramp=>$D->results[PHOTO_RAMP][$i]
,store_status=>$D->results[STORE_STATUS][$i]
,detail_desc=>ereg_replace (‘ +’, ‘ ‘, ucwords(strtolower(
$D->results[LOLCN_DETAIL_DESC][$i])))
,division=>$D->results[LOLCN_DIVISION][$i]
);
}

# now create a third hash that is in the same order as the one we
# came in with
if ($D->numrows) {
for(reset($store_numbers);$key=key($store_numbers);next($store_numbers)) {
$stores[$key]=$temp_stores[$key];
}
}
[/code]

I need to log the ip address of the user, if the state = XX. Here is how I am trying it, but it is not going insid my if state == XX logic.

[code=php]
if ($stores[$key][state] == “XX”) {
//log ip address to a flat file
echo “logging”;
$ts=date(“m/d/Y”);
$fp_ips = fopen(“/tmp/state_searches.txt”, “a”);
flock($fp_ips,2);
fwrite($fp_ips, $ts.”,”.$REMOTE_ADDR.”rn”);
flock($fp_ips,3);
fclose($fp_ips);
[/code]

Can someone please help me.

Thanks

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@NogDogNov 11.2005 — First thing to do is an echo of $stores[$key][state] and find out what it is, so you can work back from that and find out why it's not whatever value is needed to enter the if condition. If you want to examine the entire set of data for that key, do:
[code=php]
echo "<pre>";
print_r($stores[$key]);
echo "</pre>n";
[/code]

Secondly, while this should not be causing your problem, all of your array index literals should be quoted ($stores[$key]['state']). See http://www.php.net/manual/en/language.types.array.php#language.types.array.foo-bar for more info.
Copy linkTweet thisAlerts:
@jrthor2authorNov 11.2005 — I got this working, thanks
×

Success!

Help @jrthor2 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...