Linked Questions
54 questions linked to/from Replace keys in an array based on another lookup/mapping array
1 vote
1 answer
100 views
Php array : change the key number with a word
i have an array like this <?php Array ( [0] => Array ( ['a'] =>'David' ['b'] => 'Paul' [0] => 'Tom' ...
0 votes
1 answer
92 views
PHP Set Array Key to Value Inside that Array [duplicate]
I have an array which looks like (var_dump): array (size=3) 0 => array (size=8) 'id' => string '1' (length=1) 'user_id' => string '64' (length=2) 'level' => string '1' (length=1)...
0 votes
4 answers
110 views
What is the most elegant way to change a key of an array by preserve the order
I have a big associative array with over 1 000 items and I want to rename one key but the order must be preserved. I don't wont to iterate over the complete array and copy it into a new.
-1 votes
2 answers
83 views
PHP .txt to array tab delimited
Hello. im having this code: public function parse_reports($filename) { $result = array(); $fp = fopen($filename, "r"); if (($headers = fgetcsv($fp, 0, "\t")) !== FALSE) if ($...
0 votes
1 answer
58 views
Swapping out the first index of an array
I have an array: $array = [ 'foo' => 44, 'bar' => 77, 'moo' => 88, ]; Now I have two variables, $key and $value, and I want to replace the first index of the array. So remove foo and 44, and ...
0 votes
2 answers
53 views
PHP multi-dimensional array value as index
aside from doing the actual work of iterating through an associative array, pushing a value into a new array and setting that equal the array of remaining fields, is there an array function built into ...
0 votes
1 answer
55 views
How to raname some specific key name in a multidimensional array
there I have a question in array manipulate. I have a source array like this array:6 [ 0 => array:13 [ "id" => 1 "name" => "companyName" "code" => "1" "orderNumber" =&...
0 votes
0 answers
44 views
how to change value in array?
I have this array: $rows = array_map(function($item) { return (object) ['c' => [ (object) ['v' => $item->job_type, 'f' => null], (object) ['v' => intval($item->count), 'f' =&...
0 votes
1 answer
26 views
Change the key of an array
I have an array that contains year as follows. This key is going to be dynamic. NowI want to replace new_2018 to "2018". $array = array( array( "new_2018" => "john", ) ); I have ...