Подтвердить что ты не робот

Удалите сначала 2 из массива

У меня есть этот простой массив, и я хотел бы знать, как я могу остановить сегменты first 2.

if(preg_match_all('/<td[^>]*class="sourceNameCell">(.*?)<\/td>/si', $printable, $matches, PREG_SET_ORDER));{
foreach($matches as $match) {

$data = "$match[1]";

    $array = array();
    preg_match( '/src="([^"]*)"/i', $data, $array ) ;
    print_r("$array[1]") ;
}

Любая помощь будет отличной, спасибо!

4b9b3361

Ответ 1

Остановить показ или удаление?

для удаления:

$array = array();
preg_match( '/src="([^"]*)"/i', $data, $array ) ;

// The following lines will remove values from the first two indexes.
unset($array[0]);
unset($array[1]);
// This line will re-set the indexes (the above just nullifies the values...) and make a     new array without the original first two slots.
$array = array_values($array);
// The following line will show the new content of the array
var_dump($array);

Надеюсь, это поможет!

Ответ 2

Используйте array_slice:

$output = array_slice($input, 2); 

Ответ 3

Используйте array_slice($array, 2, count($array)) или сделайте, чтобы ваше регулярное выражение пропускало первые два, если это возможно.

Вы также можете дважды вызвать array_shift() в массиве. Это может быть более оптимальным, так как не нужно делать копию массива.