I have a large array with several objects, where there are several duplicates for them. I got an unique array using array_unique(PHP). Now, I need to know how to get how manny times each object was there in the original array? I have tried array_search, and loops but nothing got the correct results. Some what similar array like here, but
Tag: object
MongoDB & PHP | How to add into object that is inside an array?
I am new to MongoDB and PHP and I am trying to make an API. The current problem I have is that I am not able to add an array into an object that is inside an array (of objects). I have tried a lot, but all failed. This is the document I have so far: I would like to
How to get properties of Contact Form 7 object in PHP
I’m trying to manipulate some of the mark-up for a contact form on my site, and have managed to get the specific object I want using I have no idea what the ‘p’ key is or why it works, but nothing else seems to. It returns this object: The form string is the part i want to manipulate to add
Difficulty to understand PHP POST to REST API – mixed array and objects
I’m trying to POST data to a REST API. On Postman I can POST with success, the JSON body is: My problem is on addresses billing. I don’t know how to create the object/array correctly so the API accept it. I’m build the parameters on PHO like bellow: I get an error: “missing_entity – addresses – validation_failure”. I believe my
PHP OO – Associative array of object instances, resetting on each click
My first ever question on here as I’m completely stuck, so apologies if I leave out any key information – please let me know! I am creating a PHP Battleships game and trying to use full OO. I’m really close, however, an array for one of my classes does not hold any updates I make to it. First off, I
How to group array by key in PHP Laravel Builder query
I am new Laravel and I just want to group my array by key. Here’s what I have done so far: Code: Return Value: I just want something like this: I tried foreach to $vehicles variable but it says Cannot use object of type stdClass as array is there any way to achieve this? thanks in advance. Have a good
Laravel get union between two objects
I have the following to get all organizations the logged in user owns and to get all organizations the logged in user is member of Given that I want an object with the union of both, I tested to run then I only get one organization If I run then I got While the result is correct in the sense
PHP Class for adding two numbers
I am doing a challenge in PHP with OOP/classes and I am not sure why I am not passing the test case for two random numbers being added together. My syntax must be off somewhere, but I am very new to PHP so I am having trouble figuring it out. Here are the instructions for my challenge: Write a class
How to sort an array based on another value?
So I am pretty lost here because I don’t know what my object looks like (not sure why I can’t do print_r() to print the object). Basically from the below code, I need to sort the reviews which is $_reviews based on $percent_avg. I got the $percent_avg value from a multiple for loops and that’s what complicates things. I am
Array, array, and objects [closed]
Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 1 year ago. Improve this question I got this result in my variable What I need is all in a single array, is that possible? Something like ARRAY (objects of array