PHP Tutorial : Substract part of string with substr

Hello,

I didn’t posted for a long time because I am simply stucked into finding a subject. I made a search into my own blog and I saw that (miraculous btw) I didn’t writed yet about substr function which helps you to print only a part of a string – substract it!

<?php
$stringIs = "mystring";
$substract = substr($stringIs, 0, 3);
print $subtract; //this will print my

?>

First you declare the string you want substracted, then first number means from where to start and the last no. means where to finish.

Taddaaa!

This entry was posted in Basic PHP and tagged , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>