3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $data = '({"title": "Latest Common Alerting Protocol Files", "link": "http://www.tsunami.gov/", "description": "Tsunami Warning Centers", "modified": "Tue Jul 18 01:08:31 UTC 2017", "generator": "http://www.tsunami.gov/", "items": [ { "capFile": "/events/PAAQ/2017/07/17/ot9dh6/2/WEAK51/PAAQCAP.xml" }, { "capFile": "/events/PAAQ/2017/12/08/p0mzdc/1/WEAK53/PAAQCAP.xml" }, { "capFile": "/events/PAAQ/2017/11/30/p09376/1/WEXX32/PAAQCAP.xml" }, { "capFile": "/events/PHEB/2017/11/19/17323002/5/WEPA40/PHEBCAP.xml" }, { "capFile": "/events/PHEB/2017/12/08/17342002/1/WEPA42/PHEBCAP.xml" }, { "capFile": "/events/PHEB/2017/12/08/17342002/1/WEHW42/PHEBCAP.xml" }, { "capFile": "/events/PHEB/2017/11/04/17308000/3/WEZS40/PHEBCAP.xml" }, { "capFile": "/events/PHEB/2017/12/08/17342003/2/WEZS42/PHEBCAP.xml" }, { "capFile": "/events/PHEB/2017/12/08/17342002/1/WEGM42/PHEBCAP.xml" }, { "capFile": "/events/PHEB/2017/12/09/17343000/1/WECA42/PHEBCAP.xml" }, { "capFile": "/events/PHEB/2017/11/30/17334001/1/WECA43/PHEBCAP.xml" }, ]})'; preg_match_all("/capFile\": \"(.*?)\"/", $data, $capFilePaths); //Extract cap location URL preg_match("/link\": \"(.*?)\"/", $data, $capLocationURL); // print_r($capFilePaths[1]); // echo $capLocationURL[1]; // if(filter_var($capLocationURL[1], FILTER_VALIDATE_URL)) { // echo 'Valid URL'; // } foreach ($capFilePaths[1] as $capRelativePath) { echo $capRelativePath; }
based on rh4nI
Output for 5.6.0 - 5.6.30, hhvm-3.18.5 - 3.22.0, 7.0.0 - 7.3.0rc3
/events/PAAQ/2017/07/17/ot9dh6/2/WEAK51/PAAQCAP.xml/events/PAAQ/2017/12/08/p0mzdc/1/WEAK53/PAAQCAP.xml/events/PAAQ/2017/11/30/p09376/1/WEXX32/PAAQCAP.xml/events/PHEB/2017/11/19/17323002/5/WEPA40/PHEBCAP.xml/events/PHEB/2017/12/08/17342002/1/WEPA42/PHEBCAP.xml/events/PHEB/2017/12/08/17342002/1/WEHW42/PHEBCAP.xml/events/PHEB/2017/11/04/17308000/3/WEZS40/PHEBCAP.xml/events/PHEB/2017/12/08/17342003/2/WEZS42/PHEBCAP.xml/events/PHEB/2017/12/08/17342002/1/WEGM42/PHEBCAP.xml/events/PHEB/2017/12/09/17343000/1/WECA42/PHEBCAP.xml/events/PHEB/2017/11/30/17334001/1/WECA43/PHEBCAP.xml