Considering you have to replace the first instance of a ?
, you can use the following function:
function replaceFirst( $url, $to, $by ) {
$url = explode( "/", $url );
$arr = array();
for( $i = 0; $i < count($url); $i++ ) {
$current = $url[ $i ];
if( $current == $to ) {
if ( $by == "" ) { continue; }
else { $current = $by; }
} else if( $current == null ) { continue; }
array_push( $arr, $current );
}
return implode( $arr, "/" );
}
And you can use it like this: replaceFirst("http://phpdiscussionboard.azurewebsites.net/?/dashboards/dashboard", "?", "")
which will give you a value like: http:/phpdiscussionboard.azurewebsites.net/dashboards/dashboard
. You can fix the minor error of the http:/
there, but this should be the logic.
I am really sorry if this is not the answer you're looking for, but the question you've asked is rather vague.