Check if a value is present and store in a new array in php
<p>I have this variable with a value</p>

<pre><code>$name=GTX 980
</code></pre>

<p>And I have array that has</p>

<p>Arraynames</p>

<pre><code>Array ( [0] =&gt; Array ( [name] =&gt; GTX 970 [price] =&gt; 123 ) [1] =&gt; ( [name] =&gt; GTX 980 [price] =&gt; 321 ))
</code></pre>

<p>Now I want to check if array has name that matches to $name and store in a different array I tried this code</p>

<pre><code>for($i=0;i&lt;=count($shophive);$i++){
    if(strpos($shophive,$trimmedName ) !== FALSE){
        $newshophive[$i]=[
        'name' =&gt;$shophive[$i],
        'price' =&gt;$shophive[$i],
        'link'=&gt;$shophive[$i],
        'image'=&gt;$shophive[$i]
        ];
    }
}
</code></pre>

<p>But it gives error </p>

<p>Function name must be a string...</p>

<p>Can anyone explain what is wrong and what could be a solution?</p>