Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

php arrays: how to print only array values but not keys

This code loops through a mysql table and prints out empty/null fields. It however prints the array values and the keys like this

Array ( 
    [0] => Field "dob" on entry "1" is empty/null 
    [1] => Field "user_name" on entry "7" is empty/null
)

How do I print something like this field "dob" on entry "1" is empty/null

$sql = "SELECT * FROM userinfo";
$res = mysql_query($sql);
while ($row = mysql_fetch_array($res)) {
    foreach($row as $key => $field) {
        if(empty($field)) {
            $emptyFields[] = sprintf('Field "%s" on entry "%d" is empty/null', $key,   $row['userid']);
         }
     }
}
print_r($emptyFields);
like image 687
karto Avatar asked Mar 23 '11 10:03

karto


1 Answers

echo implode('<br>', $emptyFields);
like image 196
biakaveron Avatar answered Sep 26 '22 13:09

biakaveron