我试图在数组中显示值。第一个字母应该用大写字母打印,并且应该跳过重复的值。这是我的代码。
$user = array(array("name"=>"prusoth","language"=>array("english","tamil")),array("name"=>"venkat"," language"=>array("english","french")));
$names = array_keys($user);
$lang = array_values($user);
foreach($lang as $value)
{
print_r (array_map('ucfirst', $value));
echo "<br>"."<br>";
print_r (array_unique($value));
}
上面的代码输出是这样的。
Warning: ucfirst() expects parameter 1 to be string, array given in /home/aspire/public_html/Array.php on line 8
Array ( [name] => Prusoth [language] => )
Array ( [name] => prusoth [language] => Array ( [0] => english [1] => tamil ) )
Warning: ucfirst() expects parameter 1 to be string, array given in /home/aspire/public_html/Array.php on line 8
Array ( [name] => Venkat [language] => )
Array ( [name] => venkat [language] => Array ( [0] => english [1] => french ) )
预期输出:
name = (Prusoth,Venkat)
Language = (english,tamil,french)