尝试将字符串键和值传递到我的数组中,这里是数组
1 uploading images
2 NUMBER OF IMAGE FILES: 406
3 ESC[1G[--------------------------------------------------] 1/406ESC[0K
ESC[1G[=-------------------------------------------------] 2/406ESC[0K
ESC[1G[==------------------------------------------------] 3/406ESC[0K
ESC[1G[===-----------------------------------------------] 4/406ESC[0K
ESC[1G[====----------------------------------------------] 5/406ESC[0K
4 -----------------------------------------------
5 >> Task completed, blah blah
我的字符串var是
$array = array(
'id' =>1,
'name' => 'ahmed',
'age' => 16,
'country' => 'egypt',
$string,
);
以这种方式使用代码并不起作用所以无论如何都要在数组中插入字符串作为键和值
答案 0 :(得分:2)
试试这个
$array = array(
'id' =>1,
'name' => 'ahmed',
'age' => 16,
'country' => 'egypt',
);
$array['city'] = 'cairo';
print_r( $array);
将输出
数组([id] => 1 [姓名] => ahmed [年龄] => 16 [国家] =>埃及[city] => cairo)