我需要什么
这是数组结构(未设置之前)
[0] => Array
(
[currency] => INR
)
[1] => Array
(
[type] => General Public Tickets Adult
[amount] => 50
[comment] => (Working Days)
)
[2] => Array
(
[type] => General Public Tickets Adult
[amount] => 80
[comment] => (Saturday/ Sunday/ Holiday)
)
这是数组结构(未设置后)
[1] => Array
(
[type] => General Public Tickets Adult
[amount] => 50
[comment] => (Working Days)
)
[2] => Array
(
[type] => General Public Tickets Adult
[amount] => 80
[comment] => (Saturday/ Sunday/ Holiday)
)
这是php代码
unset($data[0]);
/* code to set the value after unset */
$data= array_values($data[0]);
答案 0 :(得分:3)
//save element to a new variable
$temp = $data[0];
//unset element
unset($data[0]);
/* code to set the value after unset */
//add element back to the array
$data[0] = $temp;
OR
//To add elements to the beginning of an array, use array_unshift
array_unshift($data,$temp);
答案 1 :(得分:1)
在新数组中取消设置之前,您需要获取货币值。如果您取消设置,之后您尝试访问它,则会导致未定义
试试这样:
$arrNew = $data[0]; //save it new array
unset($data[0]); //unset it now