gpt4 book ai didi

php - 警告 : array_values() expects parameter 1 to be array

转载 作者:行者123 更新时间:2023-11-29 06:34:19 25 4
gpt4 key购买 nike

我像这样将数据数组插入数据库:

$value['gallery_data'] = array();
$value['gallery_data'] = serialize((array(array_values("name"), array_values("url"), array_values("type")))); // LINE 843

在数据库中:

a:3:{i:0;N;i:1;N;i:2;N;}

我看到了这个错误:

Warning: array_values() expects parameter 1 to be array, string given in C:\xampp\htdocs\user\modules\editnews.php on line 843

Warning: array_values() expects parameter 1 to be array, string given in C:\xampp\htdocs\user\modules\editnews.php on line 843

Warning: array_values() expects parameter 1 to be array, string given in C:\xampp\htdocs\user\modules\editnews.php on line 843

编辑:

我需要在数据库中为多个数组插入这种格式:

a:3:{i:0;a:4:{i:0;s:48:"uploads/media/galleries/nature/butterfly_001.jpg";i:1;s:43:"uploads/media/galleries/nature/IMG_4181.jpg";i:2;s:43:"uploads/media/galleries/nature/swan_002.jpg";i:3;s:45:"uploads/media/galleries/nature/zzmed copy.jpg";}i:1;a:4:{i:0;s:19:"test_title";i:1;s:20:"test_title1";i:2;s:25:"test_title2";i:3;s:24:"677777777777777777777777";}i:2;a:4:{i:0;s:19:"test_alt";i:1;s:21:"test_alt1";i:2;s:21:"test_alt2";i:3;s:26:"77888888888888888888888888";}}

我该如何解决这个问题?

最佳答案

我觉得你在数组之前使用了 array_values 所以试试这样的东西

$value['gallery_data'] = serialize(array_values(array("key1" => "name", "key2" => "url", "key3" => "type")));

或者像这样

$value['gallery_data'] = serialize(array("name" , "url", "type")); // LINE 843

关于php - 警告 : array_values() expects parameter 1 to be array,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25904665/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com