Posted By


aludwig on 06/09/11

Tagged


Statistics


Viewed 226 times
Favorited by 0 user(s)

Related snippets


simpleStringMaker


/ Published in: PHP
Save to your folder(s)

The PHP version of simpleStringMaker has an argument to replace spaces with hyphens.


Copy this code and paste it in your HTML
  1. function simplestringmaker ( $thestring, $hyphens ) {
  2. $newstring = '';
  3. for ( $i = 0; $i < strlen( $thestring ); $i++ ) {
  4. $c = ord(substr($thestring, $i, 1));
  5. if ( ($c > 47 && $c < 58) ||
  6. ($c > 96 && $c < 123) ||
  7. ($c > 64 && $c < 91) ) {
  8. $newstring .= strtolower( chr($c) );
  9. } else if ( $c == 32 && $hyphens ) {
  10. $newstring .= '-';
  11. }
  12. }
  13. echo $newstring;
  14. }
  15.  
  16. simplestringmaker ( "It's 419: Gotta Minute..?!", 0 );

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.