wordpress convert object to array

65

<?php
/*
 * Convert Object To Array
*/

$args = array(
	'showposts' => -1,
	'post_type' => 'post',
	'post_status' => 'publish'
);
$result = new WP_Query($args);

$data = array_map(
	function( $post ) {
		return (array) $post;
	},
	$result->posts
);

Comments

Submit
0 Comments