Having this query to the database, setting to get an object:
$data = [
123 => 1000,
5 => 20000,
9 => 30000,
];
$id = 123;
$news = $pdo->query('SELECT * FROM personas')->fetchAll(PDO::FETCH_OBJ);
var_dump($news);
He var_dump
returns this:
array(2)
{
[0]=> object(stdClass)#3 (3)
{
["nombre"]=> string(4) "saul"
["cedula"]=> int(23777344)
["genero"]=> int(0)
}
[1]=> object(stdClass)#4 (3)
{
["nombre"]=> string(6) "victor"
["cedula"]=> int(25171681)
["genero"]=> int(0)
}
}
My question was: What does that #3 and #4 mean next to each object?:
object(stdClass)#3
object(stdClass)#4
Reading on php.net I found this:
$obj3 = (object)[]; // Cast empty array to object
object(stdClass)#3 (0) {}
It's like a conversion, but the#4
Taken from SO in English :
Reference: https://github.com/php/php-src/blob/master/ext/standard/var.c#L155