Linked Questions
10 questions linked to/from How to allow duplicate keys in php array
19 votes
6 answers
52k views
PHP Associative Array Duplicate Keys
I have an associative array, however when I add values to it using the below function it seems to overwrite the same keys. Is there a way to have multiple of the same keys with different values? Or is ...
1 vote
7 answers
5k views
Get column values from an associative array in php
I have an array of form: $records = array( array( 'id' => 2135, 'first_name' => 'John', 'last_name' => 'Doe', ), array( 'id' => 3245, '...
1 vote
2 answers
456 views
Finding common words in an array
I have a string: Fragrances, Beauty & Health (153) Skin Care (146) Make Up (10) Health Care & Instruments (1) Hair Care (1) I'm converting it into an array: $formatted = ...
1 vote
3 answers
73 views
split an array into groups every time there is a different group_id number in php
a dynamic array sorted from database that have some of multi similar group id's and some different ones something like this : $sourcearray = array( array(id => 1 , value => 'text'), array(...
0 votes
4 answers
76 views
Associative array with similar keys assignment
Consider I have associative array with same key values: $arr = {'MessageID' =>1 ,'MessageID' =>5 , 'MessageID' => 8}; Now I want every call to function foo() which will insert a new key ...
0 votes
1 answer
163 views
Reset keys of array elements in php
i want to reset the above as below. $_REQUEST['some_number'] => Array ( [0] => 1 [0_1] => 2 [0_2] => 3 [2] => 7 [2_1] => ...
0 votes
3 answers
89 views
How to keep an identical array key PHP [duplicate]
Could anyone let me know how can I allow duplicate keys in php array? I have already read all identical posts concerning this questions and it does not answer my question. In the following example, I ...
-3 votes
1 answer
91 views
combine two arrays has same keys
I have an array like $sele_itmid = Array ( [0] => 1 [1] => 1 [2] => 1 [3] => 4 [4] => 4 ) $fltrd_serl_batch = Array ( [0] => SAL121 [1] => SAL122 [...
-1 votes
1 answer
109 views
Array merging product with same ID
I coded this to get an array with all product in the order $sync_data = []; for ($i = 0; $i < count($request['product_id']); $i++) { $sync_data[$request->input('product_id')[$i]] = [...
0 votes
1 answer
59 views
Combining 2 Arrays So That They Display Correctly in my URL
I have an array $cat1 including cat1[0]=>16 and cat1[1]=>16. I also have this array: $url_vars = array('text'=>$event->properties['text'],'SearchResultPagerPage'=>$thenextpage); I ...