what is the wrong with this PHP function?
<p>can anybody tell me what is the wrong with this function? </p>

<p>I wrote this this function to get errors from $reg_errors array and to use those errors in different place in the same script. </p>

<pre><code>function testimonialErrors ($reg_errors) {
    if ( !empty($reg_errors) ) {
            foreach ( $reg_errors AS $error) {
                echo "&lt;li&gt;$error&lt;/li&gt;";
            }                                       
    }
    return $error; 
}
</code></pre>

<p>Then I called that function like this..</p>

<pre><code>if ( !empty($reg_errors) ) {
    echo '&lt;div class="error"&gt;
                &lt;img src="images/error.png" /&gt;
                &lt;h3&gt;Errors,&lt;/h3&gt;
                &lt;ul&gt;';
                echo testimonialErrors($reg_errors);
        echo '&lt;/ul&gt;
            &lt;/div&gt;';
}
</code></pre>

<p>But this code is not working. </p>

<p>UPDATE : this is my new code</p>

<pre><code>function tesimonialErrors ($reg_errors) {
    if ( !empty($reg_errors) ) {
            foreach ( $reg_errors AS $error) {
                echo "&lt;li&gt;$error&lt;/li&gt;";
            }                                       
    }
    return $error; 
}
</code></pre>

<p>And called it like this</p>

<pre><code>if ( !empty($reg_errors) ) {
    echo '&lt;div class="error"&gt;
                &lt;img src="images/error.png" /&gt;
                &lt;h3&gt;Errors,&lt;/h3&gt;
                &lt;ul&gt;';
                tesimonialErrors($reg_errors);
        echo '&lt;/ul&gt;
            &lt;/div&gt;';
}
</code></pre>
