PHP substr string

Posted under » PHP on 2 May 2015

Great for website scrapping.

<¿php 
$rest = substr("abcdef", 0, -1);  // returns "abcde"
$rest = substr("abcdef", 2, -1);  // returns "cde"
$rest = substr("abcdef", 4, -4);  // returns false
$rest = substr("abcdef", -3, -1); // returns "de"
?>

Sometimes you want to find the last character of a string. Say a comma or a full stop.

<¿php
substr("testers.", -1); // returns "."
?>

See other practical use.

web security linux ubuntu GIT svn Raspberry apache mysql php drupal cake symfony javascript Ajax css