Php Basics. why is there an error in the blank page of this program? How to make it output sorted results

Source: Internet
Author: User
Tags php basics blank page
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, O 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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.