Solved

PHP - get substring from string after finding other substring ?

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

Don't Cry: How Liquid Web is Ensuring Security

WannaCry is just the start. Read how Liquid Web is protecting itself and its customers against new threats.

Question has a verified solution.

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

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
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…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

729 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