Linked Questions
54 questions linked to/from Replace keys in an array based on another lookup/mapping array
0 votes
3 answers
104 views
How can I change key in the array on the php?
My array like this : $arr = array('chelsea.jpg', 'arsenal.jpg'); If I run : echo '<pre>';print_r($arr);echo '</pre>'; The result : Array ( [0] => chelsea.jpg [1] => ...
0 votes
5 answers
204 views
How do I grab a word before underscore on my array ouput [duplicate]
This is my current array which keep a first character from the value Array ( [n] => Array ( [0] => name_john ) [a] => Array ( [0] => age_30 ) ) foreach ($queryArray as $key) { $...
-3 votes
2 answers
634 views
How to rename an array? [duplicate]
I have the array like this: [0] => Array ( [fee_id] => 15 [fee_amount] => 308.5 [year] => 2009 ) I want change the name of parent to this: ...
1 vote
1 answer
419 views
How to change array keys
how do i change keys of my array like: $arrData = array('key1'=>'data1', 'key2'=>'data2') to: $arrData = array('newKey1'=>'data1', 'newKey2'=>'data2') I like it to be done withing a ...
0 votes
3 answers
311 views
Join array values and keys between two php arrays
I need to merge (sort of join) two arrays with both same keys, and in result i want to have the values of the first as keys of the second one : Example : $keyArray = [ "key1" => "...
0 votes
1 answer
283 views
How to change the array key in while loop for the table on php
Suppose that I have a table like this: id name age birthplace ------------------------------ 1 John 28 NY 2 Marry 23 LD 3 Mohamad 34 Malaysia ... I do while loop ...
1 vote
3 answers
236 views
How to convert nested array keys to indexes php
I have this array: `$arr = array( 'foo' => 'foo', 'bar' => array( 'baz' => 'baz', 'candy' => 'candy', 'vegetable' => array( 'carrot' => '...
1 vote
3 answers
453 views
In a PHP array, how to modify string keys based on the array values?
At the moment I am doing a foreach over the array, and creating a new array as I go. For example: $newMap = []; foreach ($oldMap as $key => $value) { // Apply some complex logic ...
2 votes
1 answer
218 views
PHP change array by key in place
this below simple code i want to replace [3] to 2010-01-01 and [6] to edited in array fetch. i find function to edit in place with key but thats dont work correctly PHP: while ( $aRow = ...
1 vote
3 answers
82 views
Remap keys in each row of a 2d array to replace string keys with new string keys [duplicate]
I have an array like the one below Array ( [0] => Array ( [name] => Alex [age] => 30 [place] => Texas ) [1] =&...
0 votes
0 answers
135 views
How to replace JSON key without losing its value and position using PHP
This is the JSON { "table-name": "Kiwi", "created-on": "November 20, 2021", "columns": { "Info": { "type": "...
0 votes
3 answers
64 views
Change the index of an array
I need help to change the index of an array. I have this array: $items = array('items' => array( 0 => array( 'item_id' => 1, 'item_amount' => 100, ), 1 => ...
0 votes
3 answers
67 views
Updating array keys inside of an array
My goal is to be able to update a key value inside of an array inside of an array and I'm don't know if I'm using the right php array function. BEFORE: array:2 [ "week_number" => 1 "games"...
1 vote
1 answer
84 views
Change Index Key to Name
I have built a multidimensional array for usage in a custom Wordpress query. Although it is Wordpress I feel that this is more a basic PHP question. The array that I have now outputs everything ...
0 votes
3 answers
59 views
how to replace var {$key} in array php key => aulue
I needed an assistant about replace for simple variables: $html = '<{$headtype} class="{$class}">{$text}</{$headtype}>'; $array['headtype'] = 'h1'; $array['class'] = 'classname'; $...