Posted By

metoikos on 05/26/10


Tagged

url php short


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

BrianCoyDesign


php short url


 / Published in: PHP
 

URL: http://snippets.symfony-project.org/snippet/414

  1. <?php
  2.  
  3. # Function starts here.
  4. function shorturl($url){
  5. $length = strlen($url);
  6. if($length > 45){
  7. $length = $length - 30;
  8. $first = substr($url, 0, -$length);
  9. $last = substr($url, -15);
  10. $new = $first."[ ... ]".$last;
  11. return $new;
  12. }else{
  13. return $url;
  14. }
  15. }
  16. ?>

Report this snippet  

You need to login to post a comment.