Skip to content

Instantly share code, notes, and snippets.

View vibhasbhingarde's full-sized avatar

vibhasbhingarde vibhasbhingarde

View GitHub Profile
@vibhasbhingarde
vibhasbhingarde / query.sql
Created June 4, 2014 11:49
Code to set 1 to 0 & vice versa via mysql query
mysql_query("Update awards set `active` = if(`active`=0,1,0) where `id`={$_GET['id']}");
@vibhasbhingarde
vibhasbhingarde / GetSingleKeyArray
Last active August 29, 2015 14:02
Convert Single key array to dropdown array
function GetSingularValuesArray($arr)
{
$result=array();
foreach($arr as $key=>$value):
$temp=key($value);
$result[]=is_object($value)?$value->$temp:$value[$temp];
endforeach;
return $result;
}
@vibhasbhingarde
vibhasbhingarde / gist:faf415fbac1aa7c2bb59
Created May 30, 2014 18:53
Convert assoc array with id and title array to ci_dropdown array
function array_to_select($results, $value = 'id', $key = 'title', $add_blank=false)
{
// Converts objects to arrays
if(is_object($results)) $results = get_object_vars($results);
$options = array();
if(!empty($add_blank)) $options = array(null=>$add_blank);
// Will only run if results is an array, not a string, int, etc.