This question already has an answer here:
I did a query in php and all the results are stored in an object. For example
$query = "select * from some_table";
$sth = $dbc->query($query);
$results = $sth->fetchAll();
Therefore the results of the query is stored in $results
and I have a property called name
. How can I now loop through this object $results
to change all the values of a certain property name
of the object.
</div>
Assuming name
is a public property:
for($i = 0; $i < count($results); $i++){
$results[$i]->name = ...;
}