Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to sort/filter values from Array PHP?
    primarykey
    data
    text
    <p>I need to foreach values of this array:</p> <p>My CODE:</p> <pre><code>&lt;?php print_r(array_filter($matches)); ?&gt; </code></pre> <p>Result of this CODE:</p> <pre><code>Array ( [0] =&gt; Array ( [0] =&gt; Age: // Name [1] =&gt; 22 Yrs. // Value [2] =&gt; Ethnicity: // Name [3] =&gt; Caucasian // Value [4] =&gt; Location: // Name [5] =&gt; London, United Kingdom // Value </code></pre> <p>Now I want to get this values separated/filtered like:</p> <pre><code>$location = 'London, United Kingdom'; $age = '22 Yrs.'; </code></pre> <p>So I can simply do a <code>echo $age;</code></p> <p><strong>Remark</strong>: In some cases the user have NOT set all the values. So its not guaranteed that Value Age always exists in this array. Therefore I need something like:</p> <p>If "Age:" is found in array then $age =</p> <p>How can I do this? I have totally 33 names and 33 values in this array and need to filter them all based on IF statement to be sure that the value is the right value.</p> <p><strong>Result</strong> of <code>var_dump($matches);</code> :</p> <pre><code>array(1) { [0]=&gt; array(66) { [0]=&gt; string(202) " Age: " [1]=&gt; string(157) " 22 Yrs. " [2]=&gt; string(196) " Ethnicity: " [3]=&gt; string(146) " Caucasian " [4]=&gt; string(195) " Location: " [5]=&gt; string(175) " London, United Kingdom " </code></pre> <p><strong>Result</strong> of <code>var_export($matches);</code> :</p> <pre><code>array ( 0 =&gt; array ( 0 =&gt; ' Age: ', 1 =&gt; ' 22 Yrs. ', 2 =&gt; ' Ethnicity: ', 3 =&gt; ' Caucasian ', 4 =&gt; ' Location: ', 5 =&gt; ' London, United Kingdom ', </code></pre> <p>Im newbie so if you have a better ways to do this then please advice. Thank you for your kind help.</p>
    singulars
    1. This table or related slice is empty.
    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.
 

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