We can use php built in string function to create a function which can be used in various applications to collect part of a string. Here there will be one main string. We will supply one starting landmark or staring point and one ending landmark point or ending point. The string in between these two mark points we can extract and use in our application. We will be using two important functions stristr and substr to develop this function.
We can use this function in different applications. For example let us say we want to extract all names in one xml document.
<type>PHP programmer</type>
<name>Your name is here</name>
Here we can use <name> and </name> as two landmark points to extract the name from the above string.
There are two functions. One returns the part sting without landmark points and other one includes both landmark points. Here is the code.
The first function will display part of the string without the landmarks ( welcome and programming ) but second function will keep them at starting and at end.