在codeigniter中,如何将数组传递给函数参数

时间:2013-01-17 21:25:58

标签: arrays codeigniter parameters

作为标题,我有一个库函数$this->foo->bar()。如何将$upload_data数组传递给$this->foo->bar() param?

我在控制器中有这个

$upload_data = $this->upload->data();
//$upload_data['file_name']
$this->foo->bar($upload_data);

然后我在我的库中有这个

public function bar($arr){
    $config['source_name'] = //How can I use $arr['file_name'] in here
}

我收到了这个错误 消息:非法字符串偏移'file_name'

var_dump($upload_data)

array (size=14)
 'file_name' => string '1358459309.JPG' (length=14)
 'file_type' => string 'image/jpeg' (length=10)
 'file_path' => string 'C:/wamp/www/foldering/assets/img/uploaded_photos/' (length=49)
 'full_path' => string 'C:/wamp/www/foldering/assets/img/uploaded_photos/1358459309.JPG'       (length=63)
 'raw_name' => string '1358459309' (length=10)
 'orig_name' => string '1358459309.JPG' (length=14)
 'client_name' => string '200X CNY1.JPG' (length=13)
 'file_ext' => string '.JPG' (length=4)
 'file_size' => float 30.87
 'is_image' => boolean true
 'image_width' => int 640
 'image_height' => int 480
 'image_type' => string 'jpeg' (length=4)
 'image_size_str' => string 'width="640" height="480"' (length=24)

1 个答案:

答案 0 :(得分:0)

我的错误,问题来自另一个功能