[FX.php List] Can't locate value in array
Steve Winter
steve at matatirosolutions.co.uk
Thu Jul 3 11:27:33 MDT 2008
Hi all,
I conduct a search for a particular record in my database, which results in
one found record (the way this system works, it can only find one record,
and it will always find one record, but that’s by-the-by). One of the db
fields is called Country, thus I end up with;
$studentData['data'][$studentKey]['Country'][0]
Which will usually contain the name of a country. I now need to convert this
to the ISO 3309 country code. I already use these elsewhere, when I need to
find the country from the code, so I have an array $countryList, of the
form;
$countryList = array ("AF" => "Afghanistan",
"AL" => "Albania",
"DZ" => "Algeria",
"AS" => "American Samoa",
"AD" => "Andorra",
etc...
Thus what I want to do is;
if(in_array($countryCode,
$studentData['data'][$studentKey]['Country'][0])) {
$thisCountry = current(array_keys($countryList,
$studentData['data'][$studentKey]['Country'][0]));
All good you’d think... well the answer is sort of, when I make the call to
the db, it doesn’t work... if I hard-code a value into the country field it
does...
For example, ff I do;
echo $studentData['data'][$studentKey]['Country'][0];
Then I see the country that I expect to (eg France), but the in_array does
not work.
If I insert the line;
$studentData['data'][$studentKey]['Country'][0] = ‘France’;
Then it is found...
Anyone got any idea what’s going on here...? this is seriously doing my head
in...!!
Cheers
Steve
No virus found in this outgoing message.
Checked by AVG.
Version: 7.5.524 / Virus Database: 270.4.4/1531 - Release Date: 2/07/2008
7:02 p.m.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.iviking.org/pipermail/fx.php_list/attachments/20080703/04e29599/attachment-0001.html
More information about the FX.php_List
mailing list