Php Basics. why is there an error in the blank page of this program? How can I make it output the sorted results? This post was last edited by u013071929 from 2013-12-11& lt ;? Php $ prodects & nbsp; array (HDL, Tires, 100), & nbsp; array (OIL php Basics, why does this program display a blank page, where is the error? How to make it output sorted results
This post was last edited by u013071929 at 22:59:16 on
$ Prodects = array ('till', 'tires ', 100 ),
Array ('oil ', 'Oil', 10 ),
Array ('spk', 'spark S s', 4 ));
Function compare ($ x, $ y)
{
If ($ x [1] = $ y [1]) // What are the values of x [1] and y [1?
{
Return 0;
} Else if ($ x [1] <$ y [1])
{
Return-1;
} Else
{
Return 1;
}
}
Usort ($ products, 'Company ');
Foreach ($ products as $ key)
{
Echo '|'. $ key. '| ';
}
Echo"
";
?>
Php Basics. why is there an error in the blank page of this program? How to make it output the sorted results,
Share: More
------ Solution --------------------
$ Prodects = array ('till', 'tires ', 100 ),
Array ('oil ', 'Oil', 10 ),
Array ('spk', 'spark S s', 4 ));
Usort ($ products, 'Company ');
It's clear.
------ Solution --------------------
Compare the two values of x [1] and y [1] codes.
------ Solution --------------------
The index value of each element in the array is used for comparison. the following values are marked as red:
$ Prodects = array ('till', 'tires ', 100 ),
Array ('oil ', 'Oil', 10 ),
Array ('spk', 'spark S s', 4 ));
------ Solution --------------------
Function compare ($ x, $ y)
{
Var_dump ($ x, $ y); // you will not be able to find it.
The reason for no output is that $ products does not exist.