gpt4 book ai didi

php - 给出警告 : array_values() expects parameter 1 to be array, 字符串

转载 作者:行者123 更新时间:2023-11-29 09:19:56 26 4
gpt4 key购买 nike

我正在尝试将数组转换为其值。

我得到这个:

Warning: array_values() expects parameter 1 to be array, string given in C:\xampp\htdocs\ReadNotes\mynote.php on line 42

Array ( [0] => 31 )
Warning: array_values() expects parameter 1 to be array, string given in C:\xampp\htdocs\ReadNotes\mynote.php on line 42

Array ( [0] => 32 )
Warning: array_values() expects parameter 1 to be array, string given in C:\xampp\htdocs\ReadNotes\mynote.php on line 42

Array ( [0] => 33 )
Warning: array_values() expects parameter 1 to be array, string given in C:\xampp\htdocs\ReadNotes\mynote.php on line 42

Array ( [0] => 34 )
Warning: array_values() expects parameter 1 to be array, string given in C:\xampp\htdocs\ReadNotes\mynote.php on line 42

Array ( [0] => 35 )
Warning: array_values() expects parameter 1 to be array, string given in C:\xampp\htdocs\ReadNotes\mynote.php on line 42

Array ( [0] => 36 )
Warning: array_values() expects parameter 1 to be array, string given in C:\xampp\htdocs\ReadNotes\mynote.php on line 42

Array ( [0] => 37 )
Warning: array_values() expects parameter 1 to be array, string given in C:\xampp\htdocs\ReadNotes\mynote.php on line 42

Array ( [0] => 38 )
Warning: array_values() expects parameter 1 to be array, string given in C:\xampp\htdocs\ReadNotes\mynote.php on line 42

Array ( [0] => 39 )
Warning: array_values() expects parameter 1 to be array, string given in C:\xampp\htdocs\ReadNotes\mynote.php on line 42

Array ( [0] => 40 )
Warning: array_values() expects parameter 1 to be array, string given in C:\xampp\htdocs\ReadNotes\mynote.php on line 42

Array ( [0] => 41 )
Warning: array_values() expects parameter 1 to be array, string given in C:\xampp\htdocs\ReadNotes\mynote.php on line 42

Array ( [0] => 42 )
Warning: array_values() expects parameter 1 to be array, string given in C:\xampp\htdocs\ReadNotes\mynote.php on line 42

Array ( [0] => 43 )
Warning: array_values() expects parameter 1 to be array, string given in C:\xampp\htdocs\ReadNotes\mynote.php on line 42

Array ( [0] => 44 )
Warning: array_values() expects parameter 1 to be array, string given in C:\xampp\htdocs\ReadNotes\mynote.php on line 42

Array ( [0] => 45 )
Warning: array_values() expects parameter 1 to be array, string given in C:\xampp\htdocs\ReadNotes\mynote.php on line 42

Array ( [0] => 46 )

这是我的代码:

<?php

//Starting session

session_start();

//Includes mass includes containing all the files needed to execute the full script
//Also shows homepage elements without customs

include ('includes/mass.php');

//Set the session variable

$username = $_SESSION['username'];


//Check to see if logged in

if (isset($username))

{

//Check all databases assoc with the notes for username submissions

$sql_for_username_submission = "SELECT note_id FROM notes WHERE user = '$username' ORDER BY note_id";

$get_data = mysql_query($sql_for_username_submission);

while ($data_row = mysql_fetch_assoc($get_data))

{ //Get name_id's in arrays

$name_id_array = $data_row;

//Make each one display all information associated with it.

foreach($name_id_array as $name_id)

{
//Convert name_id array to its id number

$number_on_name_id = array_values($name_id);

echo $number_on_name_id."</br>";

}

print_r (array_values($name_id_array));

}

}


?>

最佳答案

您正在迭代 $name_id,因此您通常不会在循环中完整处理 $name_id。目前还不清楚您要做什么,但作为第一步,您应该在循环外部处理 array_values()

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

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