【问题标题】:Order of Array Elements?数组元素的顺序?
【发布时间】:2011-11-06 13:47:13
【问题描述】:

我将我的数组定义为:

$data1 = array(
            'first_name'=>$this->input->post('first_name'),  
            'last_name'=>$this->input->post('last_name'),
            'company'=>$this->input->post('company'),
            'email'=>$this->input->post('email'),
            'phone'=>$phonenum,
            'username'=>strtolower($this->input->post('first_name')) . ' ' . strtolower($this->input->post('last_name'))

这个数组是从控制器发送到 CodeIgniter 中的模型的。当我尝试使用 array_splice 删除电子邮件和用户名时,无法删除正确的元素。用 xdebut 检查时,顺序已更改为:

用户名 电子邮件 名 姓 公司

谁能告诉我为什么?谢谢。 电话

【问题讨论】:

    标签: php arrays codeigniter


    【解决方案1】:

    如果您想删除电子邮件和用户名,请执行此操作;

    unset($data1['email']);
    unset($data1['username']);
    

    【讨论】:

    • 下次我会记住的。谢谢。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-07-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-03-22
    • 2015-01-12
    相关资源
    最近更新 更多