- var_dump: documentation ( source)
<?php
class SimDB {
private static $count = 0;
public static function mysqli_fetch_array($result) {
if (self::$count < 10) {
self::$count++;
return "Row" . self::$count;
} else {
return false;
}
}
public static function reset() {
self::$count = 0;
}
}
$result1 = ""; // This is simulated, so not an actual result set resource
while ($row1 = SimDB::mysqli_fetch_array($result1));
echo "Value of \$row1 => $row1\n\n";
echo "Actually store all the results\n";
SimDB::reset();
while ($row1[] = SimDB::mysqli_fetch_array($result1));
var_dump($row1);
echo "\n\n How you would actually use a while() loop\n\n";
SimDB::reset();
while ($row = SimDB::mysqli_fetch_array($result1)) {
echo "Row = $row\n";
}