Domanda

I am have a string having url

   /abc/xyz/index.php/pqr/wer

I want the result as path after index.php*

i.e;

   pqr/wer

to be stored in a variable

I did try with

  Preg_match,trim,split,substring

split splits it but then how do i get path after index.php

what if i have

   $url =/abc/xyz/index.php

it return index.php

È stato utile?

Soluzione

Try this

print str_replace('index.php/','',strstr ( $url , 'index.php'));

Altri suggerimenti

Use preg_match to get the string following index.php:

preg_match( '/index.php\/(.*)/i', '/abc/xyz/index.php/pqr/wer', $arMatches );

print_r( $arMatches );

Outputs:

Array ( [0] => index.php/pqr/wer [1] => pqr/wer )

$arMatches[1] is what you want.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top