File: /var/www/formularioinscripcion.bradford/application/helpers/utilities_helper.php
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
function limpiacaracteres($str){
$res = str_replace('ñ', 'n', $str);
$res = str_replace('/', ' ', $str);
$res = str_replace('á', 'a', $res);
$res = str_replace('é', 'e', $res);
$res = str_replace('í', 'i', $res);
$res = str_replace('ó', 'o', $res);
$res = str_replace('ú', 'u', $res);
$res = preg_replace('([^A-Za-z0-9 ])', '', $res);
return $res;
}
function format_price($price, $prefix = "$")
{
if (!empty($price)) {
$price = $prefix . number_format($price, 0, ',', '.');
} else {
$price = $prefix . "0";
}
return $price;
}
function format_miles($price)
{
if (!empty($price)) {
$price = number_format($price, 0, ',', '.');
} else {
$price = "0";
}
return $price;
}
function rut($rut)
{
return number_format(substr($rut, 0, -1), 0, "", ".") . '-' . substr($rut, strlen($rut) - 1, 1);
}
function format_rut($rut) {
$rut = preg_replace('/[^\dkK]/', '', $rut);
$numero = substr($rut, 0, -1);
$verificador = substr($rut, -1);
$numeroFormateado = number_format($numero, 0, '', '.');
$rutFormateado = $numeroFormateado . '-' . $verificador;
return $rutFormateado;
}
function clean_str_url($string='')
{
//$search = array(' - ', ' ','á','é','í','ó','ú','ñ','ü','Á','É','Í','Ó','Ú','Ñ','Ü','±','°', 'ó');
//$replace = array('-' , '-','a','e','i','o','u','n','u','A','E','I','O','U','N','U','n','-', 'o');
$search = array(' - ', ' ','á','é','í','ó','ú','ñ','ü','Á','É','Í','Ó','Ú','Ñ','Ü','À','È','Ì','Ò','Ù','à','è','ì','ò','ù','±','°', '&');
$replace = array('-' , '-','a','e','i','o','u','n','u','A','E','I','O','U','N','U','A','E','I','O','U','a','e','i','o','u','n','-', '-');
$clean_str = str_replace($search, $replace, $string);
//$search = array('$','$','/','*',')','(','=', "'", '"','!','¡',',',':',';','%','#','@','<','>','+','¿','|','.');
$search = array('\\','$','$','/','*',')','(','=', "'", '"','!','¡',',',':',';','%','#','@','<','>','+','¿','|','?');
$clean_str = str_replace($search, '', $clean_str);
$search = array('$','$','/','*',')','(','=', "'", '"','!','¡',',',':',';','%','#','@','<','>','+','¿','|','?','”',"\t", '“',"\n",'[',']','?','¿');
$clean_str = str_replace($search, '', $clean_str);
$clean_str = str_replace('--', '-', $clean_str);
$clean_str = preg_replace('~\x{00AD}~u', '', $clean_str);
$clean_str = strtolower($clean_str);
return $clean_str;
}