What are some alternative approaches to identifying a specific digit sequence within a comma-separated list in PHP?

When trying to identify a specific digit sequence within a comma-separated list in PHP, one alternative approach is to explode the list into an array and then loop through the array to find the desired digit sequence. Another approach is to use regular expressions to match the digit sequence within the list.

// Comma-separated list
$list = "10,20,30,40,50";

// Explode the list into an array
$array = explode(",", $list);

// Loop through the array to find the desired digit sequence
$desired_sequence = "30";
foreach ($array as $value) {
    if ($value == $desired_sequence) {
        echo "Digit sequence found: " . $desired_sequence;
    }
}

// Using regular expressions to match the digit sequence within the list
if (preg_match("/\b30\b/", $list)) {
    echo "Digit sequence found: " . $desired_sequence;
}