PHP String Extract

There are two functions. One returns the part sting without landmark points and other one includes both landmark points. Here is the code.
function my_strip($start,$end,$total){

$total = stristr($total,$start);
$f2 = stristr($total,$end);

return substr($total,strlen($start),-strlen($f2));
function my_strip2($start,$end,$total){ // includes both landmarks 
$total = stristr($total,$start);
$f2 = stristr($total,$end);
return substr($total,0,(strlen($total)-(strlen($f2) - strlen($end))));

$string="You are welcome to Use this site for your learning of web programming and design , php is one of the programming language";

echo $contents;
echo "<br>";
echo $contents;

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.

We have used the 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 used 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.

Read how these functions are used to read the text within title tags of page
String Functions first letter of every word to capitalize by using ucwords Change all alphabetic chars to lowercase Checking all lower case or upper case chars in a string
Subscribe to our YouTube Channel here


* indicates required
Subscribe to plus2net



    Thanks a lot for this...exactly what I was looking for.
    elden walden


    great info-will use to change data in classified ad app.


    very good information really it helped me.

    Post your comments , suggestion , error , requirements etc here

    PHP video Tutorials
    We use cookies to improve your browsing experience. . Learn more
    HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
    ©2000-2024 All rights reserved worldwide Privacy Policy Disclaimer