I have a cycle in my code where I want to extract only the first, fifth and sixth number from an array that looks like this:
Array ( [0] => 12403;644;20;46;5;285;;;; )
I am currently trying to use regular expressions to extract those numbers (in this case I need to get 12403, 5 and 285).
$contents = fgetcsv($handle);
preg_match('/^(\d+);\d+;\d+;\d+;(\d+);(\d+);*.$/', $contents, $match);
echo "first capture group: " . $match[0] . "\nsecond capture group: " . $match[1] . "\nthird capture group: " . $match[2];
This prints out empty variables. Why? Can you please help?