Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

PHP - get substring from string after finding other substring ?

Posted on 2013-06-14
1
Medium Priority
?
705 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 31

Accepted Solution

by:
Marco Gasi earned 2000 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
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.

671 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