【问题标题】:Notice: Undefined offset: 0 in C:\xampp\htdocs\Hotel\Manager\details.php on line 341注意:未定义的偏移量:C:\xampp\htdocs\Hotel\Manager\details.php 中第 341 行中的 0
【发布时间】:2018-04-10 16:04:11
【问题描述】:

我在php 中有一个数组 数组的内容是

print_r($room_array);

Array ( [1] => 102 );

现在如何将索引 1 的值更改为索引 0

【问题讨论】:

标签: php


【解决方案1】:

首先,这是一个非常不清楚的问题,但我认为这将解决您的问题。

foreach($room_array as $key=>$value) {
    unset($room_array[$key]);
    $room_array[0] = $value;
} 

我知道这是一个非常硬编码且不可扩展的脚本,但问题非常不清楚。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-05-17
    • 2016-12-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多