string manipulation substr and trim
Problem
Substituting and trimming string variables in PHP.
Solution
Similar to Perl, PHP has an extensive library of functions.
See the example tab for a few simple examples, showing the basic syntax.
Example
substr
$ php -q<<EOT
<?phpecho(substr("Hello World",0,4)."\n");
?>
EOTHell
trim
$ php -q<<EOT
<?phpecho(trim(" Hello World ")."\n");
?>
EOTHello World
Reference
Technorati Tags: PHP substr, PHP trim, PHP Coding School
Link to this post!

