Skip to content

Instantly share code, notes, and snippets.

@alexfurr
alexfurr / timepicker.php
Created February 3, 2020 15:36
Draw TimePicker in PHP
function drawTimepicker($hourValue="", $minValue="",$hourID="myHour", $minID="myMin")
{
if($hourValue==""){$hourValue=10;}
$i=1;
$html = '';
$html.='<select name="'.$hourID.'" id="'.$hourID.'">';
while($i<=23)
{
$iString = $i;
@alexfurr
alexfurr / multidimensional_array_sort_by_value
Last active February 19, 2019 13:47
Sorts a multidimensional array by value given the key name
$arrayItems = array(
array ("date" => "2018-10-21", "grade" => 50),
array ("date" => "2018-04-02", "grade" =>88),
array ("date" => "2018-03-17", "grade" =>76),
array ("date" => "2018-03-10", "grade" =>84),
array ("date" => "2019-02-03", "grade" =>67),
);
// Obtain a list of columns - last value is the key
$myCols = array_column($arrayItems, 'date');
@alexfurr
alexfurr / get_category_array.php
Created January 7, 2019 13:41
Creates multidimensional array of all categories in a WP blog
$categories = get_categories( array(
'orderby' => 'name',
'order' => 'ASC',
'hide_empty' => 0,
) );
$cats_tree = get_cat_tree(0,$categories);
function get_cat_tree($parent,$categories) {
$result = array();