Home  >  Article  >  Backend Development  >  Implementation code for traversing stdclass object in PHP

Implementation code for traversing stdclass object in PHP

高洛峰
高洛峰Original
2016-12-21 14:26:331082browse

Data that needs to be operated:

$test =Array 
( 
[0] => stdClass Object 
( 
[tags] => 最快的车,Bloodhound,SSC 
[id] => 48326888 
) 
)

The method found on the Internet is to use get_object_vars to convert the class type into an array and then use foreach to traverse it
$array = get_object_vars($test);

More traversing stdclass object in PHP For articles related to the implementation code, please pay attention to the PHP Chinese website!


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn