-2

How can I use php to get the sting bewteen the 7th and 8th /

http://uk.soccerway.com/matches/2015/01/01/england/premier-league/stoke-city-fc/manchester-united-fc/1703889/?ICID=HP_MS_01_01

so the above would grab england

emma perkins
  • 749
  • 1
  • 10
  • 28

3 Answers3

1

Something like:

$url = 'http://uk.soccerway.com/matches/2015/01/01/england/premier-league/stoke-city-fc/manchester-united-fc/1703889/?ICID=HP_MS_01_01';
$tokens = explode('/', $url);
echo $tokens[7]; // 'england'

PHP docs for explode()

Darragh Enright
  • 13,676
  • 7
  • 41
  • 48
0

php function explode does the exact thing learn more: http://php.net/manual/en/function.explode.php

Amir
  • 116
  • 2
  • 8
0

Try this:

$n = 7; $m = 8;

$str = "http://uk.soccerway.com/matches/2015/01/01/england/premier-league/stoke-city-fc/manchester-united-fc/1703889/?ICID=HP_MS_01_01";

$a = explode('/', $str);

echo $a[$n];

Like this, you can get it for any random value of n and m.

Hope this helps.

Peace! xD

Indrasis Datta
  • 8,692
  • 2
  • 14
  • 32