Skip to main content

Posts

Showing posts from March, 2023

How to get day week day names by rangs of week day names in PHP?

Get day week day names by rangs of week day names in PHP <!DOCTYPE html> <html> <body> <?php function getWeekdaysInRange($start, $end) {     $weekdays = array('Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday');     $start_index = array_search($start, $weekdays);     $end_index = array_search($end, $weekdays);     $result = array();     if ($start_index === false || $end_index === false) {         return $result;     }     $current_index = $start_index;     while ($current_index !== $end_index) {         $result[] = $weekdays[$current_index];         $current_index = ($current_index + 1) % 7;     }     $result[] = $weekdays[$end_index];     return $result; } $weekdays = getWeekdaysInRange('Saturday', 'Friday'); print_r($weekdays); ?> </body> </html>    

How to print rataing stars in PHP?

Print rataing stars in PHP? <?php         $average_reviews = round($post->average_reviews);         if(!empty($average_reviews)){             $i = 1;             while($i <= 5){                 if($i <= $average_reviews){                 ?>                 <img style="" src="<?php echo theme_url();?>/assets/img/organic.png">                 <?php                 }                 else{                     ?>                     <img style="" src="<?php echo theme_url();?>/assets/img/2017-10-10.png">                     <?php                 }                 $i++;             }             echo "(" . $average_reviews . ")";          }   ?>

How to get XML data from URL in PHP?

Get XML data from URL in PHP function get_xml_from_url($url){   $ch = curl_init();   curl_setopt($ch, CURLOPT_URL, $url);   curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);   curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13');   $xmlstr = curl_exec($ch);   curl_close($ch);   return $xmlstr; }