Jump to content

[SOLVED] Array


Daney11

Recommended Posts

Hey guys,

 

I have an array

<?php

$location = array(
'af' => 'Afghanistan',
'al' => 'Albania',
'dz' => 'Algeria',
'as' => 'American Samoa',
'ad' => 'Andorra',
'ao' => 'Angola',
'ai' => 'Anguilla',
'aq' => 'Antarctica',
'ag' => 'Antigua And Barbuda',
'ar' => 'Argentina',
'am' => 'Armenia',
'aw' => 'Aruba',
'au' => 'Australia');

?>
etc

 

And i have a mysql row called $member_nation.

 

Im using

 

<?php 

foreach ($location as $member_nation) { 
echo $member_nation;
}
?>

But it is not getting the information from the array. Any ideas?

Thanks

Link to comment
https://forums.phpfreaks.com/topic/81420-solved-array/
Share on other sites

My code works fine. What code would you like to see.

 

If i echo $member_nation it works fine.

 

For example it will echo "en".

 

<?php

$location = array(
'af' => 'Afghanistan',
'al' => 'Albania',
'dz' => 'Algeria',
'as' => 'American Samoa',
'ad' => 'Andorra',
'ao' => 'Angola',
'ai' => 'Anguilla',
'aq' => 'Antarctica',
'ag' => 'Antigua And Barbuda',
'ar' => 'Argentina',
'am' => 'Armenia',
'aw' => 'Aruba',
'au' => 'Australia');
'en' => 'England');

?>

Link to comment
https://forums.phpfreaks.com/topic/81420-solved-array/#findComment-413279
Share on other sites

that echos out every single value within my array.

 

<?php

$location = array(
'af' => 'Afghanistan',
'al' => 'Albania',
'dz' => 'Algeria',
'as' => 'American Samoa',
'ad' => 'Andorra',
'ao' => 'Angola',
'ai' => 'Anguilla',
'aq' => 'Antarctica',
'ag' => 'Antigua And Barbuda',
'ar' => 'Argentina',
'am' => 'Armenia',
'aw' => 'Aruba',
'au' => 'Australia',
'at' => 'Austria',
'aw' => 'Aruba',
'ax' => 'Aland Islands',
'az' => 'Azerbaijan',
'bs' => 'Bahamas',
'bh' => 'Bahrain',
'bd' => 'Bangladesh',
'bb' => 'Barbados',
'by' => 'Belarus',
'be' => 'Belgium',
'bz' => 'Belize',
'bj' => 'Benin',
'bm' => 'Bermuda',
'bt' => 'Bhutan',

and so on

 

I need it to echo out a specific value with is the $member_nation

Link to comment
https://forums.phpfreaks.com/topic/81420-solved-array/#findComment-413338
Share on other sites

Basically.

 

I have an array full of countrys

 

en = england

'by' => 'Belarus',

'be' => 'Belgium',

'bz' => 'Belize',

 

etc.

 

I have a $member_nation in the database which contains the 2 letter from countrys i.e. en

 

I would like to echo out the member_nation as the country name i.e. England

Link to comment
https://forums.phpfreaks.com/topic/81420-solved-array/#findComment-413347
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.