-3

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:

'searchResult' => Array
    (
        [fee_id] => 15
        [fee_amount] => 308.5
        [year] => 2009                
    )

How is possible ?

Mohsen
  • 1,295
  • 1
  • 15
  • 45
  • How is it not? Check the first answer in the linked; it says how to change the name of the key of an array-value. – klaar Oct 21 '15 at 09:44

2 Answers2

1

something like this would be possible:

<?php
//keep it in the same variable
$array['searchResult'] = $array[0];
unset($array[0]);

//create a new variable
$new_array = array('searchResult'=>$array[0]);
?>
tino.codes
  • 1,512
  • 1
  • 12
  • 23
Tanuel Mategi
  • 1,253
  • 6
  • 13
1

this is what i want!

 $searchRs['searchRs'] = $resultArr->d;
 unset($resultArr->d);
 return $searchRs;
Mohsen
  • 1,295
  • 1
  • 15
  • 45
  • As I told you, that's exactly the same answer as the accepted answer [here](http://stackoverflow.com/questions/240660/in-php-how-do-you-change-the-key-of-an-array-element). – klaar Oct 21 '15 at 12:41