3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $domains = array( 'http://wwwvagrant.royalmail.com/business', 'http://wwwvagrant.parcelforce.com', 'https://www2.postoffice.co.uk', 'http://wwwvagrant.royalmail.com', 'asdfasdfasdf', 'http://eibvagrant.royalmail.com', 'http://wwwvagrant.royalmail.com/payments', ); $doamins = array_filter($domains, function($domain) { return filter_var($domain, FILTER_VALIDATE_URL) !== FALSE; }); print_r($domains); var_dump( filter_var('dsd', FILTER_VALIDATE_UR));
based on 2Gplr
Output for 7.2.0
Array ( [0] => http://wwwvagrant.royalmail.com/business [1] => http://wwwvagrant.parcelforce.com [2] => https://www2.postoffice.co.uk [3] => http://wwwvagrant.royalmail.com [4] => asdfasdfasdf [5] => http://eibvagrant.royalmail.com [6] => http://wwwvagrant.royalmail.com/payments ) Warning: Use of undefined constant FILTER_VALIDATE_UR - assumed 'FILTER_VALIDATE_UR' (this will throw an Error in a future version of PHP) in /in/0SSvI on line 14 Warning: filter_var() expects parameter 2 to be integer, string given in /in/0SSvI on line 14 NULL
Output for 7.0.0 - 7.1.10
Array ( [0] => http://wwwvagrant.royalmail.com/business [1] => http://wwwvagrant.parcelforce.com [2] => https://www2.postoffice.co.uk [3] => http://wwwvagrant.royalmail.com [4] => asdfasdfasdf [5] => http://eibvagrant.royalmail.com [6] => http://wwwvagrant.royalmail.com/payments ) Notice: Use of undefined constant FILTER_VALIDATE_UR - assumed 'FILTER_VALIDATE_UR' in /in/0SSvI on line 14 Warning: filter_var() expects parameter 2 to be integer, string given in /in/0SSvI on line 14 NULL
Output for 5.3.22 - 5.6.28
Array ( [0] => http://wwwvagrant.royalmail.com/business [1] => http://wwwvagrant.parcelforce.com [2] => https://www2.postoffice.co.uk [3] => http://wwwvagrant.royalmail.com [4] => asdfasdfasdf [5] => http://eibvagrant.royalmail.com [6] => http://wwwvagrant.royalmail.com/payments ) Notice: Use of undefined constant FILTER_VALIDATE_UR - assumed 'FILTER_VALIDATE_UR' in /in/0SSvI on line 14 Warning: filter_var() expects parameter 2 to be long, string given in /in/0SSvI on line 14 NULL