language: PHP (php 5.4.4)
date: 1039 days 2 hours ago
link:
visibility: public
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<?php
function foo($string) {
    if (preg_match('/^@(\\d+)/', $string, $results)) {
       echo $results[1] . "\n";
    } else {
       if ($string[0] != '@')
         echo "String doesn't start with @.\n";
       else
         echo "The @ isn't followed by a number.\n";
    }
}
 
foo("@1234 foo");
foo("@hsjdf");
foo("1234 @45345");
?>