PHP string function

BR
BR used Ask the Experts™
on
Dear Experts,
I use PHP
I have a string which comes with a string and two parameters.
this is posted excatly like stringi;$p?$q

stringi;$p?$q

I need to get $p value which is between ; and ? sembols

and I need to get the $q value which is after ? question mark.

How can I get those variables with PHP?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Most Valuable Expert 2017
Distinguished Expert 2018
Commented:
You can use a regular expression with preg_match()

<?php
$incoming = "123:abc?def";

if (preg_match("/(.*?):(.*?)\?(.*)/", $incoming, $match)) {
  echo "p = {$match[2]}, q = {$match[3]}<br>";
}

Open in new window

Output
p = abc, q = def

Open in new window

BRDigital Marketing

Author

Commented:
thank you very much Julian Hansen
Most Valuable Expert 2017
Distinguished Expert 2018

Commented:
You are welcome.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial