Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialSean Flanagan
33,235 PointsSpaceship operator
Hi.
I'm not sure I get this. It says that spaceship means an integer which is less than, equal to or greater than 0 when the first value is respectively less than, equal to or greater than the second value. Does this mean the second value has to be zero? Could someone please explain spaceship to me in detail?
Cheers!
1 Answer
richporter
16,727 PointsThe spaceship returns a integer based on the difference between $a and $b
<?php
//$a <=> $b
if $a == $b
// 0
if $a < $b
// -1
if $a > $b
// 1
?>
Sean Flanagan
33,235 PointsSean Flanagan
33,235 PointsPerfect! I've upvoted and given you Best Answer for this.
Thank you Rich! :-)