I have 2 types of lines first
"/css/style.min.css HTTP/1.1" 200 7832 index.php?firstId=5&secondid=4,6,8 HTTP/1.1"
second type
"/css/style.min.css HTTP/1.1" 200 7832 /index.php?firstId=123&secondid=4,6,8" "Mozilla/5.0
I want to extract 4,6,8 one code that works for the whole case
I tried
$line = '/index.php?firstId=123&secondid=4,6,8" "Mozilla/5.0'; $nbpers = findme($line, 'secondid=', '"') ; function findme($string, $start, $end){ $string = ' ' . $string; $ini = strpos($string, $start); if ($ini == 0) return ''; $ini += strlen($start); $len = strpos($string, $end, $ini) - $ini; return substr($string, $ini, $len); }
but it only works for the first case
I also tried this regex /.*?(\d+)$/ to search for a string that ends with numbers, and I tested it on this site, but HTTP/1.1 ends with numbers, so this was not a good idea
parik source share