Answers for "use of spaceship operator in php"

PHP
1

spaceship operator php

// Integers
print (1 <=> 1); // 0
print (1 <=> 2); // -1
print (2 <=> 1); // 1
// Floats
print (1.5 <=> 1.5); // 0
print (1.5 <=> 2.5); // -1
print (2.5 <=> 1.5); // 1
// Strings
print ("a" <=> "a"); // 0
print ("a" <=> "b"); // -1
print ("b" <=> "a"); // 1
Posted by: Guest on November-24-2021
4

spaceship operator php

Return 0 if values on either side are equal
Return 1 if the value on the left is greater
Return -1 if the value on the right is greater
Posted by: Guest on October-11-2021

Browse Popular Code Answers by Language