PHP

XML to PHP array

public function xml2array($contents, $get_attributes = 0) { if (!$contents) { return array(); } if (!function_exists(‘xml_parser_create’)) { //print “‘xml_parser_create()’ function not found!”; return array(); } //Get

Read More »

Image to extension

public function image_type_to_extension($imagetype, $include_dot = false) { if (empty($imagetype)) { return false; } if ($include_dot) { $dot = ‘.’; } else { $dot = ”;

Read More »

Convert PHP array to Bootstrap grid

function bootstrapGrids($gridCols, $columns = 3) { if (is_array($gridCols) && count($gridCols) && is_numeric($columns)) { $array = array_chunk($gridCols, ceil(count($gridCols) / $columns)); $content .= ‘<div class=”row”>’; foreach ($array

Read More »

Move array to bottom or to top

function moveArrayKeyToTop(&$array, $key) { $temp = array($key => $array[$key]); unset($array[$key]); $array = $temp + $array; } function moveArrayKeyToBottom(&$array, $key) { $value = $array[$key]; unset($array[$key]); $array[$key]

Read More »

Most Popular