Thursday, April 8, 2010

substr - related questions

What is substr in php?

substr is used to return a part of a string

Two arguments can be passed to the substr

1. start value
2. length value

Examples
1. start value

substr('interview',1); // returns "nterview"
substr('interview',-2); //returns "ew"

2. Length value

substr('interview',-2,1); //the output is "e"
substr('interview',-3,-2); //the output is "i"
substr('interview',1,2); //the out put is "nt"

Your comment always welcome

No comments:

Post a Comment