<?php $urls = [ 'http://site.ru/question/new/', 'http://site.ru/2015/' ]; $result = []; foreach ($urls as $url) { if (preg_match('#http://site\.ru/\d+/#i', $url)) { $result['year'] = $url; continue; } if (preg_match('#http://site\.ru/question/.*#i', $url)) { $result['question'] = $url; continue; } } var_dump($result);
You have javascript disabled. You will not be able to edit any code.