Level 14
Any ideas?
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hi, I have been trying to find a good solution to look trough two array's and see if the same id is in both of them. So array1 is all the services we offer, array2 is all services a user has chosen before.
So this is a booking system, and I want people to be able to change or add a service to there order. So I'm trying to print out every service we offer and mark those checked which the user ordered in the first place.
These are my array's:
array1
services:Array[24]
0:Object
carSize:"Fólksbíll/Jepplingur"
created_at:null
description:"Alþrif"
id:7
price:19900
updated_at:null
visible:0
1:Object
2:Object
3:Object
...
array2
data:Object
services:Array[1]
0:Object
carSize:"Fólksbíll/Jepplingur"
created_at:null
description:"Rúðuvökvi áfylling"
id:7
pivot:Object
price:2000
updated_at:null
visible:1
I'm using belongsToMany('App\Service') relationship
Please or to participate in this conversation.