Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You want:</p> <pre><code>$data[1]['question'] </code></pre> <p>Not:</p> <pre><code>$data['1']['question'] </code></pre> <h1>Edit:</h1> <p>My answer doesn't solve his problem, rather it helped him find the actual issue. The two snippets above are <strong>exactly</strong> the same thing because PHP will cast string keys into integers if the string is a valid integer. IMO, its confusing as hell. If I key my array with a string, dag`nammit it should be keyed with a string even if that string can also be parsed into an int!</p> <p>The relevant documentation can be found <a href="http://php.net/manual/en/language.types.array.php" rel="nofollow">here</a>:</p> <blockquote> <p>The key can either be an integer or a string. The value can be of any type.</p> <p>Additionally the following key casts will occur:</p> <ol> <li><strong>Strings containing valid integers will be cast to the integer type. E.g. the key "8" will actually be stored under 8. On the other hand "08" will not be cast, as it isn't a valid decimal integer.</strong></li> <li>Floats are also cast to integers, which means that the fractional part will be truncated. E.g. the key 8.7 will actually be stored under 8.</li> <li>Bools are cast to integers, too, i.e. the key true will actually be stored under 1 and the key false under 0.</li> <li>Null will be cast to the empty string, i.e. the key null will actually be stored under "".</li> <li>Arrays and objects can not be used as keys. Doing so will result in a warning: Illegal offset type.</li> </ol> </blockquote>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

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