Title: PHP error using =&gt;
Last modified: August 31, 2016

---

# PHP error using =>

 *  [henkzuurbier](https://wordpress.org/support/users/henkzuurbier/)
 * (@henkzuurbier)
 * [10 years ago](https://wordpress.org/support/topic/php-error-using/)
 * Hi,
 * I try to load the following code, but I get a blanc page because of the following
   line:
 *     ```
       $code = [
       "AF" => "Afghanistan",
       "AX" => "Aland Islands",
       ];
       ```
   
 * `=>` is het problem.
 * How can I solve that?
 * Entire code:
 *     ```
       $ipaddress = $_SERVER['REMOTE_ADDR'];
   
       $code = [
       "AF" => "Afghanistan",
       "AX" => "Aland Islands",
       ];
   
       function ip_details($ip) {
           $json = file_get_contents("http://ipinfo.io/{$ip}/json");
           $details = json_decode($json, true);
           return $details;
       }
   
       $details = ip_details($ipaddress);
       if(array_key_exists($details['country'], $code)){
           $details['country'] = $code[$details['country']];
       }
       echo $details['country'];
       ```
   
 * [https://wordpress.org/plugins/insert-php/](https://wordpress.org/plugins/insert-php/)

Viewing 12 replies - 1 through 12 (of 12 total)

 *  [WillBontrager](https://wordpress.org/support/users/willbontrager/)
 * (@willbontrager)
 * [10 years ago](https://wordpress.org/support/topic/php-error-using/#post-7445446)
 * Hi.
 * The error code is:
 * _Parse error: syntax error, unexpected ‘[‘ … on line 4_
 * Try replacing what you have with:
 *     ```
       $code = array(
       "AF" => "Afghanistan",
       "AX" => "Aland Islands",
       );
       ```
   
 * See this page for information about error messages:
 * [http://www.willmaster.com/software/WPplugins/insert-php-wordpress-plugin-instructions.php#errormessages](http://www.willmaster.com/software/WPplugins/insert-php-wordpress-plugin-instructions.php#errormessages)
 * Will
 *  Thread Starter [henkzuurbier](https://wordpress.org/support/users/henkzuurbier/)
 * (@henkzuurbier)
 * [10 years ago](https://wordpress.org/support/topic/php-error-using/#post-7445479)
 * Hi,
 * I tried that, but that still does not work.
    I still get an error.
 * Now this is my code:
 *     ```
       $ipaddress = $_SERVER['REMOTE_ADDR'];
   
       $code = array(
       "AF" => "Afghanistan",
       "AX" => "Aland Islands",
       );
   
       function ip_details($ip) {
           $json = file_get_contents("http://ipinfo.io/{$ip}/json");
           $details = json_decode($json, true);
           return $details;
       }
   
       $details = ip_details($ipaddress);
       if(array_key_exists($details['country'], $code)){
           $details['country'] = $code[$details['country']];
       }
       echo $details['country'];
       ```
   
 *  [WillBontrager](https://wordpress.org/support/users/willbontrager/)
 * (@willbontrager)
 * [10 years ago](https://wordpress.org/support/topic/php-error-using/#post-7445486)
 * henkzuurbier, what does your error message say?
 * Will
 *  Thread Starter [henkzuurbier](https://wordpress.org/support/users/henkzuurbier/)
 * (@henkzuurbier)
 * [10 years ago](https://wordpress.org/support/topic/php-error-using/#post-7445504)
 * The error message I get is:
 * `Parse error: syntax error, unexpected '=', expecting ')' in /home/public_html/
   wp-content/plugins/insert-php/insert_php.php(48) : eval()'d code on line 5`
 *  [WillBontrager](https://wordpress.org/support/users/willbontrager/)
 * (@willbontrager)
 * [10 years ago](https://wordpress.org/support/topic/php-error-using/#post-7445505)
 * henkzuurbier, the message means there’s a syntax error in your code at line 3.
   The software found a “=” character where it expected a “)” character.
 * I don’t see it in your example code, but it’s somewhere in your live code. Otherwise,
   the error wouldn’t be there.
 * Will
 *  Thread Starter [henkzuurbier](https://wordpress.org/support/users/henkzuurbier/)
 * (@henkzuurbier)
 * [10 years ago](https://wordpress.org/support/topic/php-error-using/#post-7445506)
 * This is my entire code.
 * What am I missing?
 *     ```
       [insert_php]
       $ipaddress = $_SERVER['REMOTE_ADDR'];
   
       $code = array(
       "AF" => "Afghanistan",
       "AX" => "Aland Islands",
       "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",
       "AZ" => "Azerbaijan",
       "BS" => "Bahamas the",
       "BH" => "Bahrain",
       "BD" => "Bangladesh",
       "BB" => "Barbados",
       "BY" => "Belarus",
       "BE" => "Belgium",
       "BZ" => "Belize",
       "BJ" => "Benin",
       "BM" => "Bermuda",
       "BT" => "Bhutan",
       "BO" => "Bolivia",
       "BA" => "Bosnia and Herzegovina",
       "BW" => "Botswana",
       "BV" => "Bouvet Island (Bouvetoya)",
       "BR" => "Brazil",
       "IO" => "British Indian Ocean Territory (Chagos Archipelago)",
       "VG" => "British Virgin Islands",
       "BN" => "Brunei Darussalam",
       "BG" => "Bulgaria",
       "BF" => "Burkina Faso",
       "BI" => "Burundi",
       "KH" => "Cambodia",
       "CM" => "Cameroon",
       "CA" => "Canada",
       "CV" => "Cape Verde",
       "KY" => "Cayman Islands",
       "CF" => "Central African Republic",
       "TD" => "Chad",
       "CL" => "Chile",
       "CN" => "China",
       "CX" => "Christmas Island",
       "CC" => "Cocos (Keeling) Islands",
       "CO" => "Colombia",
       "KM" => "Comoros the",
       "CD" => "Congo",
       "CG" => "Congo the",
       "CK" => "Cook Islands",
       "CR" => "Costa Rica",
       "CI" => "Cote d"Ivoire",
       "HR" => "Croatia",
       "CU" => "Cuba",
       "CY" => "Cyprus",
       "CZ" => "Czech Republic",
       "DK" => "Denmark",
       "DJ" => "Djibouti",
       "DM" => "Dominica",
       "DO" => "Dominican Republic",
       "EC" => "Ecuador",
       "EG" => "Egypt",
       "SV" => "El Salvador",
       "GQ" => "Equatorial Guinea",
       "ER" => "Eritrea",
       "EE" => "Estonia",
       "ET" => "Ethiopia",
       "FO" => "Faroe Islands",
       "FK" => "Falkland Islands (Malvinas)",
       "FJ" => "Fiji the Fiji Islands",
       "FI" => "Finland",
       "FR" => "France, French Republic",
       "GF" => "French Guiana",
       "PF" => "French Polynesia",
       "TF" => "French Southern Territories",
       "GA" => "Gabon",
       "GM" => "Gambia the",
       "GE" => "Georgia",
       "DE" => "Germany",
       "GH" => "Ghana",
       "GI" => "Gibraltar",
       "GR" => "Greece",
       "GL" => "Greenland",
       "GD" => "Grenada",
       "GP" => "Guadeloupe",
       "GU" => "Guam",
       "GT" => "Guatemala",
       "GG" => "Guernsey",
       "GN" => "Guinea",
       "GW" => "Guinea-Bissau",
       "GY" => "Guyana",
       "HT" => "Haiti",
       "HM" => "Heard Island and McDonald Islands",
       "VA" => "Holy See (Vatican City State)",
       "HN" => "Honduras",
       "HK" => "Hong Kong",
       "HU" => "Hungary",
       "IS" => "Iceland",
       "IN" => "India",
       "ID" => "Indonesia",
       "IR" => "Iran",
       "IQ" => "Iraq",
       "IE" => "Ireland",
       "IM" => "Isle of Man",
       "IL" => "Israel",
       "IT" => "Italy",
       "JM" => "Jamaica",
       "JP" => "Japan",
       "JE" => "Jersey",
       "JO" => "Jordan",
       "KZ" => "Kazakhstan",
       "KE" => "Kenya",
       "KI" => "Kiribati",
       "KP" => "Korea",
       "KR" => "Korea",
       "KW" => "Kuwait",
       "KG" => "Kyrgyz Republic",
       "LA" => "Lao",
       "LV" => "Latvia",
       "LB" => "Lebanon",
       "LS" => "Lesotho",
       "LR" => "Liberia",
       "LY" => "Libyan Arab Jamahiriya",
       "LI" => "Liechtenstein",
       "LT" => "Lithuania",
       "LU" => "Luxembourg",
       "MO" => "Macao",
       "MK" => "Macedonia",
       "MG" => "Madagascar",
       "MW" => "Malawi",
       "MY" => "Malaysia",
       "MV" => "Maldives",
       "ML" => "Mali",
       "MT" => "Malta",
       "MH" => "Marshall Islands",
       "MQ" => "Martinique",
       "MR" => "Mauritania",
       "MU" => "Mauritius",
       "YT" => "Mayotte",
       "MX" => "Mexico",
       "FM" => "Micronesia",
       "MD" => "Moldova",
       "MC" => "Monaco",
       "MN" => "Mongolia",
       "ME" => "Montenegro",
       "MS" => "Montserrat",
       "MA" => "Morocco",
       "MZ" => "Mozambique",
       "MM" => "Myanmar",
       "NA" => "Namibia",
       "NR" => "Nauru",
       "NP" => "Nepal",
       "AN" => "Nederlandse Antillen",
       "NL" => "Nederland",
       "NC" => "New Caledonia",
       "NZ" => "New Zealand",
       "NI" => "Nicaragua",
       "NE" => "Niger",
       "NG" => "Nigeria",
       "NU" => "Niue",
       "NF" => "Norfolk Island",
       "MP" => "Northern Mariana Islands",
       "NO" => "Norway",
       "OM" => "Oman",
       "PK" => "Pakistan",
       "PW" => "Palau",
       "PS" => "Palestinian Territory",
       "PA" => "Panama",
       "PG" => "Papua New Guinea",
       "PY" => "Paraguay",
       "PE" => "Peru",
       "PH" => "Philippines",
       "PN" => "Pitcairn Islands",
       "PL" => "Poland",
       "PT" => "Portugal, Portuguese Republic",
       "PR" => "Puerto Rico",
       "QA" => "Qatar",
       "RE" => "Reunion",
       "RO" => "Romania",
       "RU" => "Russian Federation",
       "RW" => "Rwanda",
       "BL" => "Saint Barthelemy",
       "SH" => "Saint Helena",
       "KN" => "Saint Kitts and Nevis",
       "LC" => "Saint Lucia",
       "MF" => "Saint Martin",
       "PM" => "Saint Pierre and Miquelon",
       "VC" => "Saint Vincent and the Grenadines",
       "WS" => "Samoa",
       "SM" => "San Marino",
       "ST" => "Sao Tome and Principe",
       "SA" => "Saudi Arabia",
       "SN" => "Senegal",
       "RS" => "Serbia",
       "SC" => "Seychelles",
       "SL" => "Sierra Leone",
       "SG" => "Singapore",
       "SK" => "Slovakia (Slovak Republic)",
       "SI" => "Slovenia",
       "SB" => "Solomon Islands",
       "SO" => "Somalia, Somali Republic",
       "ZA" => "South Africa",
       "GS" => "South Georgia and the South Sandwich Islands",
       "ES" => "Spain",
       "LK" => "Sri Lanka",
       "SD" => "Sudan",
       "SR" => "Suriname",
       "SJ" => "Svalbard & Jan Mayen Islands",
       "SZ" => "Swaziland",
       "SE" => "Sweden",
       "CH" => "Switzerland, Swiss Confederation",
       "SY" => "Syrian Arab Republic",
       "TW" => "Taiwan",
       "TJ" => "Tajikistan",
       "TZ" => "Tanzania",
       "TH" => "Thailand",
       "TL" => "Timor-Leste",
       "TG" => "Togo",
       "TK" => "Tokelau",
       "TO" => "Tonga",
       "TT" => "Trinidad and Tobago",
       "TN" => "Tunisia",
       "TR" => "Turkey",
       "TM" => "Turkmenistan",
       "TC" => "Turks and Caicos Islands",
       "TV" => "Tuvalu",
       "UG" => "Uganda",
       "UA" => "Ukraine",
       "AE" => "United Arab Emirates",
       "GB" => "United Kingdom",
       "US" => "United States of America",
       "UM" => "United States Minor Outlying Islands",
       "VI" => "United States Virgin Islands",
       "UY" => "Uruguay, Eastern Republic of",
       "UZ" => "Uzbekistan",
       "VU" => "Vanuatu",
       "VE" => "Venezuela",
       "VN" => "Vietnam",
       "WF" => "Wallis and Futuna",
       "EH" => "Western Sahara",
       "YE" => "Yemen",
       "ZM" => "Zambia",
       "ZW" => "Zimbabwe",
       );
   
       function ip_details($ip) {
       $json = file_get_contents("http://ipinfo.io/{$ip}/json");
       $details = json_decode($json, true);
       return $details;
       }
   
       $details = ip_details($ipaddress);
       [/insert_php]
       ```
   
 *  [WillBontrager](https://wordpress.org/support/users/willbontrager/)
 * (@willbontrager)
 * [10 years ago](https://wordpress.org/support/topic/php-error-using/#post-7445508)
 * Well, I don’t see any errors on line 5, which your error message says is the 
   case.
 * But there is one on line 59.
 * `"CI" => "Cote d"Ivoire",`
 * You’ll need to do something with that double-quotation mark within the value.
   Escaped or changed to an HTML entity.
 * What you’ll need to do is put your code on a stand-alone web page and test it
   and fix it. This forum is to assist with Insert PHP issues, not to debug people’s
   code.
 * Put your PHP code on a .php web page, upload it to your server, and run it. Once
   it runs without error, then use it with Insert PHP.
 * Will
 *  Thread Starter [henkzuurbier](https://wordpress.org/support/users/henkzuurbier/)
 * (@henkzuurbier)
 * [10 years ago](https://wordpress.org/support/topic/php-error-using/#post-7445509)
 * I tried this code and that does also not work, same error:
 * It looks like the => sign is causing the issue.
    Is it possible to use that sign?
 * By removing the following section, everything works fine:
 *     ```
       $code = array(
       "AF" => "Afghanistan",
       "AX" => "Aland Islands",
       );
       ```
   
 * This code does also not load:
 *     ```
       $ipaddress = $_SERVER['REMOTE_ADDR'];
   
       $code = array(
       "AF" => "Afghanistan",
       "AX" => "Aland Islands",
       );
   
       function ip_details($ip) {
           $json = file_get_contents("http://ipinfo.io/{$ip}/json");
           $details = json_decode($json, true);
           return $details;
       }
   
       $details = ip_details($ipaddress);
       if(array_key_exists($details['country'], $code)){
           $details['country'] = $code[$details['country']];
       }
       echo $details['country'];
       ```
   
 *  [WillBontrager](https://wordpress.org/support/users/willbontrager/)
 * (@willbontrager)
 * [10 years ago](https://wordpress.org/support/topic/php-error-using/#post-7445510)
 * Perhaps something was overlooked.
 * When you post code for Insert PHP, use the Text tab, not the Visual tab.
 * Otherwise, “>” and other characters will be converted to HTML entities, which
   would break your PHP code.
 * Will
 *  Thread Starter [henkzuurbier](https://wordpress.org/support/users/henkzuurbier/)
 * (@henkzuurbier)
 * [9 years, 11 months ago](https://wordpress.org/support/topic/php-error-using/#post-7445616)
 * Hi Will,
 * Sadly, it still does not work.
    I did create an entire new page, set tit to text
   tab and placed it, but that it still does break down the page.
 * Still the => is het problem.
    When removing the following part, it works perfect:
 *     ```
       $code = array(
       "AF" => "Afghanistan",
       "AX" => "Aland Islands",
       );
       ```
   
 * My entire code looks like this:
 *     ```
       [insert_php]
   
       $ipaddress = $_SERVER['REMOTE_ADDR'];
   
       $code = array(
       "AF" => "Afghanistan",
       "AX" => "Aland Islands",
       );
   
       function ip_details($ip) {
           $json = file_get_contents("http://ipinfo.io/{$ip}/json");
           $details = json_decode($json, true);
           return $details;
       }
   
       $details = ip_details($ipaddress);
       if(array_key_exists($details['country'], $code)){
           $details['country'] = $code[$details['country']];
       }
       echo $details['country'];
   
       [/insert_php]
       ```
   
 *  [WillBontrager](https://wordpress.org/support/users/willbontrager/)
 * (@willbontrager)
 * [9 years, 11 months ago](https://wordpress.org/support/topic/php-error-using/#post-7445617)
 * Perhaps another plugin in your installation or something else that affects your
   installation is interfering. The code you provided works on my WP version 4.5.2
 * I’m just guessing, now, but perhaps it will work if you get rid of the “>” character.
   Something like this:
 *     ```
       $code = array();
       $code["AF"] = "Afghanistan";
       $code["AX"] = "Aland Islands";
       ```
   
 * Will
 *  Thread Starter [henkzuurbier](https://wordpress.org/support/users/henkzuurbier/)
 * (@henkzuurbier)
 * [9 years, 11 months ago](https://wordpress.org/support/topic/php-error-using/#post-7445618)
 * Works great!! Thanks a lot

Viewing 12 replies - 1 through 12 (of 12 total)

The topic ‘PHP error using =>’ is closed to new replies.

 * ![](https://ps.w.org/insert-php/assets/icon-256x256.gif?rev=3523853)
 * [Woody Code Snippets – Insert PHP, CSS, JS, and Header/Footer Scripts](https://wordpress.org/plugins/insert-php/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/insert-php/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/insert-php/)
 * [Active Topics](https://wordpress.org/support/plugin/insert-php/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/insert-php/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/insert-php/reviews/)

## Tags

 * [php](https://wordpress.org/support/topic-tag/php/)

 * 12 replies
 * 2 participants
 * Last reply from: [henkzuurbier](https://wordpress.org/support/users/henkzuurbier/)
 * Last activity: [9 years, 11 months ago](https://wordpress.org/support/topic/php-error-using/#post-7445618)
 * Status: not resolved