Skip to content

Tag: arrays

Natural array sorting with proper decimal support in PHP

I want to sort an array with numbers in natural order, so numbers with a bigger value come after smaller ones like this: This is what I get as result, which is not the result I need, decimals are not threated correctly. There is already a similar question Array Sorting in php for decimal values but no fitting…

How to loop through div per div

Horrible title aside, I currently have a dynamic form that has tasks, and per tasks, statuses. The amount of tasks and status can vary. What I’m trying to do is submit the task name, status name, and colors tied to that status. I’m submitting the form via js and the only different thing is creatin…

PHP updating multiple elements of sub-array of MongoDB document

I have the following document structure. I am trying to update specific values inside the holes sub-array: Each holes Array element is an Object representing the score on a golf hole, with various properties (fields). I am trying to provide the ability to update the holeGross field ONLY for each score. On my …

how to use explode for an array of objects

I have an array like that: I want to do a foreach in “prerequis”: I need in second foreach to use in $value2[‘champ’] where $value2[‘champ’] is “tranche.fus.fup_id. So I need to explode that to have [‘tranche’][‘fus’][‘fup_id’]. How…