Create the function sortArray() public function sortArray(&$array, $subkey=”id”, $sort_ascending=true) { if (count($array)) $temp_array[key($array)] = array_shift($array); foreach($array as $key => $val){ $offset = 0; $found = false; foreach($temp_array as $tmp_key => $tmp_val) { if(!$found and strtolower($val[$subkey]) > strtolower($tmp_val[$subkey])) { $temp_array = array_merge( (array)array_slice($temp_array,0,$offset), array($key => $val), array_slice($temp_array,$offset) ); $found = true; } $offset++; } if(!$found) $temp_array […]
echo “PATH=/opt/plesk/php/7.1/bin:$PATH” >> ~/.bash_profile Replace the version number with the one you have set. Then close out the terminal and reopen. Run php -v and you should see the correct version. php -v PHP 7.4.27 (cli) (built: Dec 23 2021 14:48:17) ( NTS ) Copyright (c) The PHP Group Zend Engine v3.4.0, Copyright (c) […]
function auth_pwgen(){ $pw = ”; $c = ‘bcdfghjklmnprstvwz’; //consonants except hard to speak ones $v = ‘aeiou’; //vowels $a = $c.$v; //both //use two syllables… for($i=0;$i < 2; $i++){ $pw .= $c[rand(0, strlen($c)-1)]; $pw .= $v[rand(0, strlen($v)-1)]; $pw .= $a[rand(0, strlen($a)-1)]; } //... and add a nice number $pw .= rand(10,99); return $pw; }
// Disable gateway based on country function payment_gateway_disable_country( $available_gateways ) { global $woocommerce; if ( isset( $available_gateways[‘cod’] ) && $woocommerce->customer->get_country() <> ‘IN’ ) { unset( $available_gateways[‘cod’] ); } return $available_gateways; } add_filter( ‘woocommerce_available_payment_gateways’, ‘payment_gateway_disable_country’ );
$available_gateways = WC()->payment_gateways->get_available_payment_gateways();
Each YouTube video has 4 generated images. They are predictably formatted as follows: http://img.youtube.com/vi/<insert-youtube-video-id-here>/0.jpg http://img.youtube.com/vi/<insert-youtube-video-id-here>/1.jpg http://img.youtube.com/vi/<insert-youtube-video-id-here>/2.jpg http://img.youtube.com/vi/<insert-youtube-video-id-here>/3.jpg The first one in the list is a full size image and others are thumbnail images. The default thumbnail image (ie. one of 1.jpg, 2.jpg, 3.jpg) is: http://img.youtube.com/vi/<insert-youtube-video-id-here>/default.jpg For the high quality version of the thumbnail use a url similar […]
//Easy way to print from php or just plain command line. exec(“lpr [ options ] [ filename … ]”); //Gettinga little Fancy cat thesis.txt | lpr //Another example exec(“lpr -P printer -r filename.txt”); Read more in at this Link
str_replace(‘”‘, “”, $string); preg_replace(“//”, “”, $string); C-style quotes: preg_replace(“/\/\/.*?\n/”, “\n”, $string); CSS-style quotes: preg_replace(“/\/*.*?\*\//”, “”, $string); bash-style quotes: preg-replace(“/#.*?\n/”, “\n”, $string);