この正規表現の何が問題なのか誰にも教えてもらえますか:
色の最初の出現を返すことを意図していますが、最後のものを返し続けます。
$string = "Red is a sexy colour. Yellow too. Pink too. Blue too. Green too. Hehe.";
preg_match('/^.*\b(red|green|blue|yellow)\b.*$/i', $string, $colour );
echo $colour[1]; // Should say Red, but returns Green... o.O
$colour の print_r ショー:
Array ( [0] => Red is a sexy colour. Yellow too. Pink too. Blue too. Green too. Hehe.
[1] => Green )