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; …

Get current date and time with timezone in wordpress

+10 Get current date and time with timezone in wordpress <?php $timezone = wp_timezone_string(); //Get the timezone $today_date = get_date_from_gmt($timezone,date(“Y-m-d”)); $current_time = current_time( “H:i:s”, $gmt = 0 ); // Echo the variable and enjoy ?>  

How to detect You tube Channel / Playlist / Video ID in you tube account

+10 Step 1. First go to the  browser and  login with your google account Step 2.  And Open YouTube  Step 3. After open you tube please view at left side bar (Navigation Drawer) and click it for open and select here Setting Menu Step 4. Here you view Advanced settings and click it for open …

How to remove duplicate option from Select dropdown using JQuery

+30 How to remove duplicate option from Select dropdown using JQuery <!DOCTYPE html> <html lang=”en”> <head> <title>Codelizar – Remove duplicate options</title> <link rel=”stylesheet” href=”https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css”> <script src=”https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js”></script> <script src=”https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js”></script> </head> <body> <h1>Method 1</h1> <select id=”sel_box”> <option value=””>All Equipment</option> <option value=”1″>Dumbells</option> <option value=”2″>Plates</option> <option value=”3″>Rodes</option> <option value=”4″>Benches</option> </select> <h1>Method 2</h1> <select id=”sel_box_another”> <option value=””>All Equipment</option> <option value=”1″>Dumbells</option> …

How to run or execute multi query in mysqli PHP

+10 How to run or execute multi query in mysqli PHP $conn = mysqli_connect(“localhost”,”username”,”password”,”database_name”); /* Test Connection */ if (mysqli_connect_errno()) { printf(“Your Connection failed: %s\n”, mysqli_connect_error()); exit(); } $query = “DELETE FROM `demo_table` WHERE `mid`=’$id’;INSERT INTO `MyTable` (`firstname`, `lastname`, `emailid`) VALUES (‘Brain’, ‘Colls’, ‘[email protected]’)”; mysqli_multi_query($conn,$query); // Execute multi query at one time  

Add or set value in data-attribute using JQuery

+20 Add or set value in data-attribute JQuery <html> <head> <title>Codelizar JQuery Data Attribute</title> <script src=’https://code.jquery.com/jquery-3.4.1.js’></script> </head> <body> <div id=”mybox” data-boxval=”98″></div> <div id=”newbox” data-mygroup=””></div> </body> <script type=’text/javascript’> var new_value = $(‘#mybox’).data(‘boxval’); //get the value from div $(‘#newbox’).data(‘mygroup’,new_value); //set the value </script> </html>