phpeveryday.com

The best tutorial of php, php framework, php strategies, object oriented oriented,


String: Removing Characters from The Edge of String

Tag: string, substr   Category: PHP Basic
post: 03 Feb 2008 read: 250


PHP String Tips: If you want to remove first or last n characters from string, you can use substr() function. The substr() function enables you to cut strings into smaller strings.


<?
$string = 'abcdef'; 
echo substr($string, 1); // return bcdef
echo substr($string, 2); // return cdef
?>

Following sample when we use 3 arguments:


<?
$string = 'abcdef'; 
echo substr($string, 0, 4); // return abcd
echo substr($string, 1, 3); // return bcd
?>



| Give Your Opinion | Recommend
Share and Bookmark to: These icons link to social bookmarking sites where readers can share and discover new web pages.
digg del.icio.us technorati Ma.gnolia BlinkList

Recommended articles by other readers:
Web Services: How PHP Kiss VB.NET? (Part 1)
Chart: How to Build Cool Animation Real Time Chart
Joomla: Fast Road to Understand Component Programming
Email: Send Attachement Mail
mod_rewrite - Part 1: create your "fantasy" URL

What do You Think?
Your Name *:
Email *:
(Will not be published)
Website/URL:
Your Comment *:
* Required


615
posting