3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $app_filename = "AntivirusSecurity_02_cb-508164-ce_ac8a0e5e-35f8-4c7b-b591-7e28cab94b4e.apk"; //$app_filename = "AntivirusSecurity_02_[508164]_ac8a0e5e-35f8-4c7b-b591-7e28cab94b4e.apk"; $app_filename = "AntivirusSecurity_748164.apk"; $app_filename = "AntivirusSecurity_3542683-1.apk"; $app_filename = "AntivirusSecurity_123456.apk"; function extract_click_id_from_filename($app_filename=''){ // New standard format: $click_id_fence_beginning = 'cb-'; $click_id_fence_end = '-ce'; preg_match_all("^{$click_id_fence_beginning}(.*?){$click_id_fence_end}^", $app_filename, $fields); if(!empty($fields[1][0])) return $fields[1][0]; // Legacy format 1: $click_id_fence_beginning = 'AntivirusSecurity_'; $click_id_fence_end = '\.apk'; preg_match_all("^{$click_id_fence_beginning}([0-9]*{4,}?){$click_id_fence_end}^", $app_filename, $fields); if(!empty($fields[1][0])) return $fields[1][0]; // Legacy format 2: $click_id_fence_beginning = 'AntivirusSecurity_'; $click_id_fence_end = '-'; preg_match_all("^{$click_id_fence_beginning}([0-9]*{4,}?){$click_id_fence_end}^", $app_filename, $fields); print_r($fields); if(!empty($fields[1][0])) return $fields[1][0]; } echo extract_click_id_from_filename($app_filename);
Output for 5.2.0 - 7.1.0
Warning: preg_match_all(): Compilation failed: nothing to repeat at offset 28 in /in/cl19J on line 22 Warning: preg_match_all(): Compilation failed: nothing to repeat at offset 28 in /in/cl19J on line 30 Array ( [0] => Array ( ) [1] => Array ( ) )
Output for 4.3.11 - 5.1.6
Warning: preg_match_all(): Compilation failed: nothing to repeat at offset 28 in /in/cl19J on line 22 Warning: preg_match_all(): Compilation failed: nothing to repeat at offset 28 in /in/cl19J on line 30 Array ( )
Output for 4.3.0 - 4.3.10
Warning: Compilation failed: nothing to repeat at offset 28 in /in/cl19J on line 22 Warning: Compilation failed: nothing to repeat at offset 28 in /in/cl19J on line 30 Array ( )