Jump to content
Fórum Script Brasil
  • 0

Exemplo 4.24 -Classificando com sort() ,Livro Aprendendo PHP de David Skalar Página 98


Question

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Array</title>
</head>
<body>


<?php

//Exemplo 4.24 da Página 98 do Livro Aprendendo PHP de David Sklar


// Classificando com sort()

$dinner = array('Sweet Corn and Asparagus',
'Lemon Chicken',
'Braised Bamboo Fungus');
$mel= array('breakfast' => 'Walnut Bun',
'lunch' =>'Cashew Nuts and White Mushroons',
'snack' => 'Dried Mulberries',
'dinner' => 'Eggplant with Chili Sauce');

print "Before Sorting:\\n";

foreach ($dinner as $key => $value) {


print " \\$dinner: $key $valeu\\n";

}

foreach ($meal as $key => $value){
print "\\ $meal: $key $value\\n";
}

sort($dinner);
sort($meal);

print "After Sorting:\\n";
foreach ($dinner as $key => $value) {
print " \\$dinner: $key $value\\n";
}
foreach($meal as $key => $value) {
print " \\$meal: $key $value\\n";
}

?>

</body>

</html>

_____________________________Esse código acima está apresentando os seguintes erros (abaixo) _______________________________________________________________
Before Sorting:
Notice: Undefined variable: valeu in C:\\xampp\\htdocs\\php_ead\\cursophp\\apphpdspag98.ex4.24.php on line 30
$dinner: 0
Notice: Undefined variable: valeu in C:\\xampp\\htdocs\\php_ead\\cursophp\\apphpdspag98.ex4.24.php on line 30
$dinner: 1
Notice: Undefined variable: valeu in C:\\xampp\\htdocs\\php_ead\\cursophp\\apphpdspag98.ex4.24.php on line 30
$dinner: 2
Notice: Undefined variable: meal in C:\\xampp\\htdocs\\php_ead\\cursophp\\apphpdspag98.ex4.24.php on line 34

Warning: Invalid argument supplied for foreach() in C:\\xampp\\htdocs\\php_ead\\cursophp\\apphpdspag98.ex4.24.php on line 34

Warning: sort() expects parameter 1 to be array, null given in C:\\xampp\\htdocs\\php_ead\\cursophp\\apphpdspag98.ex4.24.php on line 39
After Sorting: $dinner: 0 Braised Bamboo Fungus $dinner: 1 Lemon Chicken $dinner: 2 Sweet Corn and Asparagus
Warning: Invalid argument supplied for foreach() in C:\\xampp\\htdocs\\php_ead\\cursophp\\apphpdspag98.ex4.24.php on line 45

Obs: Já conferi 5 vezes esse código e está exatamente como no livro .
Link to post
Share on other sites

1 answer to this question

Recommended Posts

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Forum Statistics

    • Total Topics
      148692
    • Total Posts
      644524
×
×
  • Create New...