The structure which I want to get:
[
{
id: 'some id',
name: 'Name',
},
{
id: 'some id',
name: 'Name',
},
// more arrays
]
and here is how I get the data
$students = get_posts( $args )
foreach ( $students as $student ) {
$id = $student->ID;
$name = $student->post_title;
}
now how can I convert the above data to the structure I want? thanks
{}is an object, and[]is an array