Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/249.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 数组元素无法通过索引访问_Php_Arrays_Cakephp - Fatal编程技术网

Php 数组元素无法通过索引访问

Php 数组元素无法通过索引访问,php,arrays,cakephp,Php,Arrays,Cakephp,我在$this->request->data对象中有一个数组: Array ( [Reseller] => Array ( [id] => 1 [name] => Abdus Sattar Bhuiyan [mobile] => 01673050495 [email] => kuet.absb@yahoo.com ) ) 给出: Array

我在$this->request->data对象中有一个数组:

Array ( [Reseller] => Array ( [id] => 1 [name] => Abdus Sattar Bhuiyan [mobile] => 01673050495 [email] => kuet.absb@yahoo.com ) ) 给出:

 Array
        (
            [id] => 1
            [name] => Abdus Sattar Bhuiyan 
            [mobile] => 01673050495
            [email] => kuet.absb@yahoo.com
        )
当我试图通过pr$requestData['Reseller']['id']再次显示id时;它再次显示未定义的索引分销商。下面的方法同样有效: $data=$requestData['Reseller']; pr$数据['id']

我的公关职能是:

function pr($data){
echo '<pre>'; print_r($data); echo '</pre>';
}

这个问题让我哭了。任何帮助都将不胜感激

你能打印$requestData吗?只是想知道你为什么要这么做->请求->数据['Reseller']['id'];而不是$this->request->data->Reseller->id;?对我可以打印这个阵列。尝试在分销商和idShow之间添加[0]请查看您的PHP代码,如何获得$requestData?
function pr($data){
echo '<pre>'; print_r($data); echo '</pre>';
}
function changePersonalInfo() {
        $this->layout = 'ajax';
        $this->render('nothing');
        $this->loadModel('Reseller');
        $requestData =$this->request->data;
        $data = $requestData['Reseller'];
        pr($data['id']); exit;
        $this->Reseller->id = $this->request->data['Reseller']['id'];
        $this->Reseller->save($this->request->data['Reseller']);

        $msg = ' <div class="alert alert-success">
                                <button type="button" class="close" data-dismiss="alert">×</button>
                                <strong>Chanes Saved</strong> 
                            </div>';


        $return['msg'] = $msg;
        $reseller = $this->Reseller->findById($this->Reseller->id);
        $return['reseller'] = $reseller['Reseller'];
        $result = json_encode($return);
        echo $result;
    }
function saveData(formid, processUrl, updateSection) {

    $(formid).submit(function (event) {
        event.preventDefault();

        //  Abort any pending request

        var fields = "input, select, button, textarea";
        var $form = $(this);
        var $inputs = $form.find(fields);
        var serializedData = $form.serialize();
        $inputs.prop("disabled", true);
      var  request = $.ajax({
            url: processUrl,
            dataType: 'json',
            type: "post",
            data: serializedData
        });
        // Callback handler that will be called on failure
        request.fail(function (jqXHR, textStatus, errorThrown) {
            console.log(
                    "The following error occurred: " +
                    textStatus, errorThrown
                    );

        });
        request.always(function () {
            // Reenable the inputs
            $inputs.prop("disabled", false);
        });

        request.done(function (response, textStatus, jqXHR) {
            $(updateSection+' .bubblingG').fadeOut(2000,function(){
                 $(updateSection).before(response.msg);
                 if(updateSection == "#personalInfo"){
                    $('#avatar #ResellerEmail').val(response.reseller.email);
                 }
            });//({visibility: 'hidden'}, 2000, 'linear');//css("visibility", "hidden");

        });

        // Prevent default posting of form
//        event.preventDefault();
    });
}