Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>you can use foreach then just use <a href="http://php.net/manual/en/language.variables.variable.php" rel="nofollow">variable variables</a>:</p> <pre><code>foreach($array as $keyName =&gt; $value) { //in here you have the key in $keyName and the value in $value $$keyName = $value; } </code></pre> <p><strong>EDIT:</strong> not 100% sure what you want with the 'array' and 'results' but I think the problem there is that the arrays are children of the other arrays you can modify the code to check if the value is an array like so:</p> <pre><code>// 1. flatten out the array to contain only single values (no arrays) do { $containedArrayValue = false; foreach($array as $key =&gt; $value) { if(is_array($value)) { $array = array_merge($array,$value); $containedArrayValue = true; } unset($array[$key]); } } while($containedArrayValue); // 2. run the code above to get variables for each one foreach($array as $keyName =&gt; $value) $$keyName = $value; </code></pre> <p>is this what you want to happen? otherwise please give the outcome you want and I will fix it to be like that...</p> <p><strong>SECOND EDIT:</strong> I will leave the code above because even though it wasn't what you were looking for it may help someone else later. The data structure you have is an array where each value is either a string, number, or another array. Each of those arrays is the same way so you can have many layers deep (7 in this example). The layer you care about would be in $array[results][person] if this whole variable was stored in $array; This is an array of 'people' arrays so the first person will be at $array[results][person][0] the second will be at $array[results][person][1] etc. inside of each person you can get the data you want as </p> <pre><code>$firstName = $array[results][person][0][firstName]; $lastName = $array[results][person][0][lastName]; $email = $array[results][person][0][email]; </code></pre> <p>now what if there was more than one person? we can make arrays of these variables as such:</p> <pre><code>foreach($array[results][person] as $personNum =&gt; $personData) { $firstNames[] = $personData[firstName]; $lastNames[] = $personData[lastName]; $emails[] = $personData[email]; } </code></pre> <p>and now you have the data you want in these three arrays. The empty brackets is just shorthand for the next empty element of the array so in the loop I am just building up these arrays member by member. If you wanted to get something more complex like their password hint you could get at it by doing $personData[weblink][passwordHint] inside the loop. For more info check out the <a href="http://php.net/manual/en/control-structures.foreach.php" rel="nofollow">foreach syntax</a> and <a href="http://www.webcheatsheet.com/PHP/multidimensional_arrays.php" rel="nofollow">multidimensional arrays</a>.</p>
    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