How to change stdClass object to array in PHP

00 If you have array like this Array ( [0] => stdClass Object ( [page_id] => 269 ) [1] => stdClass Object ( [page_id] => 887 ) [2] => stdClass Object ( [page_id] => 544 ) ) Solution $converted_arr = json_decode(json_encode($your_stdobj_array), true); OR foreach ($your_stdobj_arrayas $value){ $array[] = $value->page_id; }

How to Create array with dynamic key and value in PHP

+10 How to Create array with dynamic key and value in PHP // Here table name is – ‘monthly_student’ $query = mysqli_query(‘SELECT * FROM `monthly_student`’); $assoc_Array = array(); // empty array while($row = mysqli_fetch_array($query)){ // Put the values into the array, no other variables required $assoc_Array[$row[‘rollno’]] = $row[‘studentname’]; // Here ‘rollno’ and ‘studentname’ is column …

How to create dyanmic post in wordpress – PHP code

+10 How to create dyanmic post in wordpress /* Create POST object*/ global $wpdb; $cdl_post = array(); $cdl_post[‘post_title’] = “My Dynamic Post”; $cdl_post[‘post_content’] = “Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry’s standard dummy text ever since the 1500s”; $cdl_post[‘post_status’] = “publish”; $cdl_post[‘post_author’] = 1; …