Skip to content
Advertisement

Remove first 2 from Array

I have this simple array and I’d like to know how I can stop the first 2 segments from showing.

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]") ;
}

Any help would be great, Thanks!

Advertisement

Answer

Stop from showing or removing?

for removing:

$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);

Hope this helps!

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement