There is a string, there are many substrings of the type /dream/aim/ . How to pull aim and further everything that is enclosed in slashes after a dream ? Something tried to navayat, not furychit:

 preg_match_all("/\/dream\/(*\w)\//", $string, $matches); 
  • * - any number of occurrences of the preceding character or trappings. Including zero. - Maxim Stepanov
  • Completely an example of the line and what you need to bring - marrk2
  • preg_match_all("~/dream/([^/]+)~", $string, $matches); print_r($matches[1]); - Wiktor Stribiżew
  • Come on my expression? - Wiktor Stribiżew

1 answer 1

It is possible and simpler:

 $data = array_slice(explode('/', "/dream/aim/preg"),2); var_dump($data); 

Result:

 C: \ wamp64 \ www \ 2017 \ 17_03_02_sscanf \ index.php: 3:
 array (size = 2)
   0 => string 'aim' (length = 3)
   1 => string 'preg' (length = 4)