Note that there are some explanatory texts on larger screens.

plurals
  1. POWhat is wrong with this php array?
    text
    copied!<pre><code>$canada_territories = array("British Columbia" =&gt; "British Columbia", "Manitoba" =&gt; "Manitoba", "New Brunswick" =&gt; "New Brunswick", "Newfoundland and Labrador" =&gt; "Newfoundland and Labrador", "Nova Scotia" =&gt; "Nova Scotia", "Northwest Territories" =&gt; "Northwest Territories", "Nunavut" =&gt; "Nunavut", "Ontario" =&gt; "Ontario", "Prince Edward Island" =&gt; "Prince Edward Island", "Quebec" =&gt; "Quebec", "Saskatchewan" =&gt; "Saskatchewan", "Yukon" =&gt; "Yukon"); print_r($canada_territories); </code></pre> <p>Ends up being</p> <pre><code>Array ( [British Columbia [Manitoba]] =&gt; British Columbia [Manitoba] =&gt; Manitoba [New Brunswick] =&gt; New Brunswick [Newfoundland and Labrador] =&gt; Newfoundland and Labrador [Nova Scotia] =&gt; Nova Scotia [Northwest Territories] =&gt; Northwest Territories [Nunavut] =&gt; Nunavut [Ontario] =&gt; Ontario [Prince Edward Island] =&gt; Prince Edward Island [Quebec] =&gt; Quebec [Saskatchewan] =&gt; Saskatchewan [Yukon] =&gt; Yukon ) </code></pre> <p>ritish Columbia [Manitoba] is where it starts to go wrong by adding part of the next array item</p> <p>What is causing this?</p> <p>I am trying to build this array to populate a dropdown form,i don't know enough about array, do I even really need to add British Columbia to the array twice to be able to cycle through them?</p> <p>This is what I usually use but it usually has a key and value that I set, on this case I need to show the value twice below where I usually show 2 different values</p> <pre><code>foreach ($state_array as $sid =&gt; $statename) { print '&lt;option value=' . $sid . $selected . '&gt;' . $statename . '&lt;/option&gt;'; } </code></pre> <p><strong>UPDATE</strong></p> <p>I wasnt wrapping with tags and it showed up how I posted in chrome, when I view source it is actually correct</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload