Page 1 of 1
simple array issues
Posted: Sat Jul 29, 2006 2:05 pm
by Charles256
Code: Select all
$access_name = $guid_arr[$guid_id];
where guid_arr is an array with one of the entries
'{C458257A-E596-4B9F-8AAC-873190CDD87A}' => '3daypass'
and guid_id is
{C458257A-E596-4B9F-8AAC-873190CDD87A}
if i go $guid_arr['that string'] it works fine but if i do it as you see at the top it doesn't work.why?
Posted: Sat Jul 29, 2006 2:27 pm
by feyd
Are you 100% sure $guid_id is that string? var_dump() it. I'd guess it has whitespace in there somewhere, or a null character.
Posted: Sat Jul 29, 2006 2:28 pm
by volka
Cannot reproduce it either
Code: Select all
<?php
$guid_arr = array(
'{C458257A-E596-4B9F-8AAC-873190CDD87A}'=>'3daypass',
'{C458257A-E596-4B9F-8AAC-873190CDD87B}'=>'7daypass',
'{C458257A-E596-4B9F-8AAC-873190CDD87C}'=>'14daypass',
'{C458257A-E596-4B9F-8AAC-873190CDD87D}'=>'21daypass'
);
$guid_id = '{C458257A-E596-4B9F-8AAC-873190CDD87A}';
echo $access_name = $guid_arr[$guid_id];
?>
works fine.
Posted: Sat Jul 29, 2006 2:46 pm
by Charles256
yep.there was a bit of white space.slapping trim on it.i'll let ya know.
Posted: Sat Jul 29, 2006 3:19 pm
by Charles256
yep.slap trim on it and good to go.