Solved

PHP - get substring from string after finding other substring ?

Posted on 2013-06-14
1
641 Views
Last Modified: 2013-06-14
What is the best way to get the string that come up after 'page=' using PHP?

I just need to extract 216,dogs, 230 & Contact US from the following.

225about_our_shopping_cartpage=216
about_our_shopping_cartpage=dogs
232testing_oe_shopping_cartpage=230
232testing_our_cartpage=Contact US
0
Comment
Question by:sabecs
1 Comment
 
LVL 30

Accepted Solution

by:
Marco Gasi earned 500 total points
Comment Utility
Use this:

$str1 = '225about_our_shopping_cartpage=216';
$str2 = 'about_our_shopping_cartpage=dogs';
$str3 = '232testing_oe_shopping_cartpage=230';
$str4 = '232testing_our_cartpage=Contact US';

$res1 = end(explode('=', $str1));
$res2 = end(explode('=', $str2));
$res3 = end(explode('=', $str3));
$res4 = end(explode('=', $str4));

echo $res1 . '<br>' . $res2 . '<br>' . $res3 . '<br>' . $res4 . '<br>' .

Open in new window

0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
This article discusses four methods for overlaying images in a container on a web page
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now