Are you opposed to using a for loop? Because you could write one to accomplish this.
It looks like you've already got the data from the database. That's the most important thing in regards to performance, and if you are doing that well, this part shouldn't affect performance. For Loops from my understanding are the fastest iterative construct that PHP has to offer - it doesn't hurt to try and optimize later.
$count = count($buildings);
for($i = 0; $i < $count; $i++ ) {
if ($buildings[$i]->building_data->building_data_id == 5) {
return $buildings[$i];
}
}
return 'no buildings of id 5';
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community