Skip to content

Tag: arrays

How to check the key of next index of arrays in PHP?

I have an PHP array : I want to check the keys of each array and if not match need to add it on every array. Expecting output like: If the key is not exist need to add the key with value zero. Is that possible? I tried with array_key_exists() function… But I’m not sure where I want to check,

How use array_map for order by word in php

I have this two-dimensional array And I would like this result: I am a beginner, so there may be things that are not done this way. Please understand 😉 I know how to run two foreach one inside the other and look for matches, but I think an array map would be faster and cleaner, right? Maybe I’m wrong ab…

merge two equal structural multi-arrays with different data

i can’t believe that i can’t find a solution to this seemingly simple problem, and i tried everything. i have two multi arrays: the first one: the second one has the exact same structure, but with new data: what i need mergin both multi-arrays is this result: but i can’t get this result with…

How to merge array with custom value in laravel?

I need help to concatenate 2 arrays with custom values, I’ve used tried array_merge() and array_combine(), the result is always not same with what I want please help me guys Array 1 Array 2 I want the output be like this how to get the result like that Answer There isn’t any function that will aut…