I want to filter an array by first letter in PHP
<pre><code>&lt;?php
function filter($fst, $arr){
$new_arr=array();

    for($i=0;$i&lt;=(count($arr)-1);$i++){
        if(substr($arr[$i], 0, 1) == $fst){
            $new_arr[] = $fst;
        }
    }
    return $new_arr;
}



$list = Array("Apparel","Associations","Building/Grounds","Building/Materials",
              "Dispensing","Disposables","Distributors");

$new_list[]=filter("A", $list);

for($i=0;$i&lt;=(count($new_list)-1);$i++){ 
    echo '&lt;li&gt;&lt;a href="?id='.$i.'"&gt;'.$new_list[$i].'&lt;/a&gt;&lt;/li&gt;'; 
}

?&gt;
</code></pre>

<p>I have created a function named filter() to filter the contents of an array that starts with a character like "a". It does not work at the moment.</p>
