Skip to content
Advertisement

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 answer was

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 creating an array from the colors.

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 PHP website, this is using a POST

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 to use explode with that ? thanks everyone 🙂 Answer you can use laravel data_get helper:

How to remove specific element from array in php

I have the following array I want to remove 60b6a8a38cf91900695dd46b from the multiple_assignee array. I have tried with the following code: But it is not removing that element. The intention is I don’t want to repeat the 60b6a8a38cf91900695dd46b assignee in the multiple assignee array. I have also tried with the following code: But it is resulting as rather than Thank

Advertisement