I have a PHP code when I want to show info to the browser it shows me:
Notice: Array to string conversion in
Can you help me please? I want to show this information from function because I don't want to create new while for every request.
function get_school($school_code){
global $conn,$Lang;
$school_select = $conn->query("SELECT * FROM schools WHERE code='$school_code'");
$school_exs = $school_select->num_rows;
if ($school_exs != 0) {
$show = array();
while ($school_info = mysqli_fetch_array($school_select)) {
$nestedData = array();
$nestedData[] = $school_info['id'];
$nestedData[] = $school_info['name'];
$nestedData[] = $school_info['code'];
$nestedData[] = $school_info['type'];
$nestedData[] = $school_info['wilaya'];
$nestedData[] = $school_info['baladiya'];
$nestedData[] = $school_info['capacity'];
$nestedData[] = $school_info['phone'];
$nestedData[] = $school_info['email'];
$nestedData[] = $school_info['adress'];
$nestedData[] = $school_info['arabic_name'];
$nestedData[] = $school_info['direction'];
$nestedData[] = $school_info['language'];
$show[] = $nestedData;
}
}else{
}
return $show;
}
echo get_school($admin_school_code);
You are returning an array therefore you cannot use echo
.
Try to var_dump(get_school($admin_school_code))
or print_r(get_school($admin_school_code))