Solved

PHP - get substring from string after finding other substring ?

Posted on 2013-06-14
1
657 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 31

Accepted Solution

by:
Marco Gasi earned 500 total points
ID: 39249576
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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

776 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