Trouver la position d'un élement de tableau
bonjour
je voudrais retourner l'élément inconnu d'un tableau qui se se situe après un autre connu
j'ai une chaine http://domaine.fr/index.php/categorie/page
je veux trouver categorie qui se trouve toujours après index.php
je récupères comme ça >>
Code:
1 2 3 4 5 6 7 8 9
| $pageURL = 'http';
if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
$pageURL .= "://";
if ($_SERVER["SERVER_PORT"] != "80") {
$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
} else {
$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
}
$curPage = split("/", $pageURL); |
il me faut la position de index.php pour retourner
Code:
return $curPage[$position + 1];
comment faire avec un foreach par exemple (ou autre) ?
merci