Set value of variable dynamically in php
<p>I have array as:</p>

<pre><code>$name = array (
 array ( 'id' =&gt; 'name1',
         'link' =&gt; 'name1.php',
         'imagepath' =&gt; 'images/name1.png',
         'textname' =&gt; 'Display Name1' 
 ),
 array ( 'id' =&gt; 'name2',
         'link' =&gt; 'name2.php',
         'imagepath' =&gt; 'images/name2.png',
         'textname' =&gt; 'Display Name2' 
 ),
 array ( 'id' =&gt; 'name2',
         'link' =&gt; 'name2.php',
         'imagepath' =&gt; 'images/name2.png',
         'textname' =&gt; 'Display Name3' 
 ),
)
</code></pre>

<p>I wrote a function in php to change textname and imagepath on click of a href link.</p>

<p>php function is:</p>

<pre><code>function Subject ($subjectCode)
{
global $name;
if (is_array($name))
{
    foreach ($name as $element)
    {
        if ($element['id'] == $subjectCode)
        {
            $selectCourse = $element;
            $Name = $selectCourse['textname'];
            $Thumb = $selectCourse['imagepath'];
            echo '&lt;a href="'.$selectCourse['link'].'"&gt;'.$selectCourse['textname'].'&lt;/a&gt;';
        }
    }
}
}
</code></pre>

<p>call to function on other page is as follows:</p>

<pre><code>&lt;?php Subject('name1'); ?&gt;
</code></pre>

<p>This sets name for 3 time, it also sets href path, But it does not set imagepath and textname. I don't know how to do it.</p>

<p>I want to change image and textname in other php file as:</p>

<p>if i click on Display Name1, it links to name1.php and that page displays textname as Display Name1 and image name1.png</p>

<p>Help me please.</p>

<p>Thanks in advance.</p>
