note 61486 added to language.functions
| From: | tompittlik at osu1 dot php dot net | Date: | Sun, 05 Feb 2006 07:53:00 +0000 |
| Subject: | note 61486 added to language.functions | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-103014@lists.php.net to get a copy of this message | ||
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:
<?
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"
?>
----
Server IP: 203.202.10.60
Probable Submitter: 59.167.19.163
----
Manual Page -- http://www.php.net/manual/en/language.functions.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+61486
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+61486&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+61486&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+61486&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+61486&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+61486&report=yes&reason=non-english
Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+61486&report=yes&reason=already+in+docs
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+61486&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+61486&report=yes
Search -- http://master.php.net/manage/user-notes.php