Link to home
Start Free TrialLog in
Avatar of error77
error77

asked on

remove part of string in php

Hi all,

I have a string in a variable and I need to remove the question mark and everything before it.

Here is the string:

/website/docs/Ed/?ref=documents

I need to remove the Question mark itself and everything before it.

Hope you can help

Thanks

Avatar of darren-w-
darren-w-
Flag of United Kingdom of Great Britain and Northern Ireland image

<?php
$string = "/website/docs/Ed/?ref=documents";
echo substr(strrchr($string, "?"),1);
//returns ref=document
?>

Open in new window

Avatar of error77
error77

ASKER

hmm it's returning:

bool(false)

Does it matter that the string is an array?    There's only 1 instance of the question mark :o/
ASKER CERTIFIED SOLUTION
Avatar of darren-w-
darren-w-
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of error77

ASKER

It's still returning:

bool(false)


This is what I'm doing:

$myNewArray = substr(strrchr($myArray[0], "?"),1);

Then:

var_dump(myNewArray);

I'm I doing this wrong?

Thanks

Avatar of error77

ASKER

OK, this is the contents of the array:

array(4) {
    ["onene"]=> string(38) "/website/docs/Ed/?ref=documents"
    ["counter"]=> string(1) "0"
    ["request"]=> string(424) "gfddfg-yE4.ggffJlWfffiJ9"
    ["ggfTwo"]=> string(199) "\"uid=1223321232&access=543%7C2._I543tBpygZGg__.340.1qadgebf3vlgU&expires=12965&sig=66555544\""
   
    }

Hope this helps

Avatar of error77

ASKER

Got it working in the end. Thanks :)