Note that there are some explanatory texts on larger screens.

plurals
  1. POMultidimensional array, if array value exists, create new array following that value
    text
    copied!<p>I have decided to set up an array to differentiate certain values. If I look to find a certain value in the array, I'd like to use the rest of the data within this value I have searched:</p> <pre><code>Array ( [0] =&gt; Array ( [id] =&gt; 123 [0] =&gt; Array ( [name] =&gt; Burger Joint [pluralName] =&gt; Burger Joints [shortName] =&gt; Burgers ) ) [1] =&gt; Array ( [id] =&gt; 617 [0] =&gt; Array ( [name] =&gt; reeeJoint [pluralName] =&gt; reeeJoints [shortName] =&gt; reee ) ) [2] =&gt; Array ( [id] =&gt; 12355 [0] =&gt; Array ( [name] =&gt; LeftJoint [pluralName] =&gt; LeftJoints [shortName] =&gt; Left ) ) [4] =&gt; Array ( [id] =&gt; 526 [0] =&gt; Array ( [name] =&gt; asdfJoint [pluralName] =&gt; asdfJoints [shortName] =&gt; asdf ) ) ) </code></pre> <p>I'd like to do some kind of search where if there's a value with <code>123</code>, it will only get a new array with everything in the 123 id array (in this case is the first one).</p> <p>What is the best practice in finding this?</p> <p>Thanks!</p> <p>Edit:</p> <p>Based on some comments, I was able to come up with a new way of setting my array. However I'm still wondering the same question which way to tackle showing if value exists:</p> <pre><code>foreach($values as $value) { ... $categoriesExtract[$id] = array($category_stringArray2Sugg); } </code></pre> <p>gives me this array:</p> <pre><code>Array ( [123] =&gt; Array ( [0] =&gt; Array ( [name] =&gt; Burger Joint [pluralName] =&gt; Burger Joints [shortName] =&gt; Burgers ) ) [617] =&gt; Array ( [0] =&gt; Array ( [name] =&gt; reeeJoint [pluralName] =&gt; reeeJoints [shortName] =&gt; reee ) ) [12355] =&gt; Array ( [0] =&gt; Array ( [name] =&gt; LeftJoint [pluralName] =&gt; LeftJoints [shortName] =&gt; Left ) ) [526] =&gt; Array ( [0] =&gt; Array ( [name] =&gt; asdfJoint [pluralName] =&gt; asdfJoints [shortName] =&gt; asdf ) ) ) </code></pre>
 

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