Solved

PHP - get substring from string after finding other substring ?

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Ajax and PHP 9 54
MSSQL - Lock Row from reading by other programs 9 62
Generate PDF from MySQL using PHP 3 56
if statement malfunction 5 25
These days socially coordinated efforts have turned into a critical requirement for enterprises.
This article discusses four methods for overlaying images in a container on a web page
The viewer will learn how to dynamically set the form action using jQuery.
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.

730 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