note 61486 deleted from language.functions by googleguy
| From: | googleguy@php.net | Date: | Mon, 24 Aug 2015 09:59:45 +0000 |
| Subject: | note 61486 deleted from language.functions by googleguy | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-203427@lists.php.net to get a copy of this message | ||
Note Submitter: tom pittlik
----
This is a way of formatting different strings with different mandatory functions and is especially
useful when processing form data or outputting database fields using structured configuration files:
<?php
function format_string($string,$functions) {
$funcs = explode(",",$functions);
foreach ($funcs as $func) {
if (function_exists($func)) {
$string = $func($string);
}
}
return $string;
}
echo format_string(" <b> this is a test </b>",
"strip_tags,strtoupper,trim");
// outputs "THIS IS A TEST"
?>