Update the format_string function
This commit is contained in:
+28
-13
@@ -724,23 +724,38 @@ function switch_module_is_running($fp, $mod) {
|
|||||||
//switch_module_is_running('mod_spidermonkey');
|
//switch_module_is_running('mod_spidermonkey');
|
||||||
|
|
||||||
//format a number (n) replace with a number (r) remove the number
|
//format a number (n) replace with a number (r) remove the number
|
||||||
function format_string ($format, $data) {
|
function format_string($format, $data) {
|
||||||
|
//preset values
|
||||||
$x=0;
|
$x=0;
|
||||||
$tmp = '';
|
$tmp = '';
|
||||||
for ($i = 0; $i <= strlen($format); $i++) {
|
|
||||||
$tmp_format = strtolower(substr($format, $i, 1));
|
//count the characters
|
||||||
if ($tmp_format == 'x') {
|
$format_count = substr_count($format, 'x');
|
||||||
$tmp .= substr($data, $x, 1);
|
$format_count = $format_count + substr_count($format, 'R');
|
||||||
$x++;
|
$format_count = $format_count + substr_count($format, 'r');
|
||||||
}
|
|
||||||
elseif ($tmp_format == 'r') {
|
//format the string if it matches
|
||||||
$x++;
|
if ($format_count == strlen($data)) {
|
||||||
}
|
for ($i = 0; $i <= strlen($format); $i++) {
|
||||||
else {
|
$tmp_format = strtolower(substr($format, $i, 1));
|
||||||
$tmp .= $tmp_format;
|
if ($tmp_format == 'x') {
|
||||||
|
$tmp .= substr($data, $x, 1);
|
||||||
|
$x++;
|
||||||
|
}
|
||||||
|
elseif ($tmp_format == 'r') {
|
||||||
|
$x++;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$tmp .= $tmp_format;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $tmp;
|
if (strlen($tmp) == 0) {
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return $tmp;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//get the format and use it to format the phone number
|
//get the format and use it to format the phone number
|
||||||
|
|||||||
Reference in New Issue
Block a user