Houston I have a Problem. I have this preg_match_all
the response is many array with duplicate numbers (the original data has these duplicates). I need to eliminate duplicate numbers and transfer to one variable. I Try with array_unique()
and array_merge()
. Thx for your help.
preg_match_all('~x">([^"]*)<\/h4>|[0-9]{5}~',$preg_data,$item, PREG_SET_ORDER);
Output:
Array ( )
Array ([0] => x"> 13:30 - Denver</h4> [1] => 13:30 - Denver)
Array ( )
Array ([0] => 69275)Array([0] => Array([0] => 69275[1] => 69275))
Array ([0] => 69275)Array([0] => Array([0] => 69275[1] => 69275))
Array ([0] => 69275)Array([0] => Array([0] => 69275[1] => 69275))
Array ()
Array ([0] => x"> 16:00 - Miami</h4>[1] => 16:00 - Miami)
Array ()
Array ([0] => 69275)Array([0] => Array([0] => 69275[1] => 69280))
Array ([0] => 69275)Array([0] => Array([0] => 69275[1] => 69280))
Array ([0] => 69275)Array([0] => Array([0] => 69275[1] => 69280))
if (@preg_match_all('/([0-9]{5})/',$item[0],$match, PREG_SET_ORDER)); { print_r($match);}
Array ( )
Array ( [0] => Array ( [0] => 69268 [1] => 69268 ))
Array ( [0] => Array ( [0] => 69268 [1] => 69268 ))
Array ( )
Array ( [0] => Array ( [0] => 69270 [1] => 69270 ))
Array ( [0] => Array ( [0] => 69270 [1] => 69270 ))
Array ( )
Array ( )
Array ( [0] => Array ( [0] => 69270 [1] => 69270 ))
Array ( [0] => Array ( [0] => 69270 [1] => 69270 ))
Array ( )
Array ( )
Array ( [0] => Array ( [0] => 69270 [1] => 69270 ))
Array ( [0] => Array ( [0] => 69270 [1] => 69270 ))
Array ( )
I use this combinations
preg_match_all('~x">([^"]*)<\/h4>|[0-9]{5}~',$preg_data,$data_mach);
$data_clean= array_values(array_filter(array_unique($data_mach[0])));
preg_mach to extrac data array_unique to eliminate duplicates array_filter to eliminate blank array_values to work only numbers. Done.