How to use the PHP space ship operator
This article mainly introduces "how to use PHP space ship operator". In daily operation, I believe many people have doubts about how to use PHP space ship operator. Xiaobian consulted all kinds of data and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts about "how to use PHP space ship operator". Next, please follow the editor to study!
PHP space ship operator
Comparison operator $a $b space ship operator [php7+]
When $an is less than, equal to, and greater than $b, an int value of less than, equal to, and greater than 0 is returned, respectively.
/ / example echo 1 1; / / 0echo 1 2; / /-1echo 2 1; / / 1
Working with scen
Before PHP7:
Usort ($arr, function ($a, $b) {if ($a)
< $b) { return -1; } elseif ($a >B) {return 1;} else {return 0;}})
After PHP7:
Usort ($arr, function ($a, $b) {return $a $b;}). At this point, the study on "how to use the PHP space ship operator" is over. I hope to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!