$User_Age = 20; preg_match("/(?=.*?(Age: 18))/is", $text)) Hello how can I compare the

age here if it is greater or less than the age typed by the user
The question is how do I get the age of a message written by the user.

4 ответов

37 просмотров

If you only need the number of age, get only digit from $text and compare it

$user_age = 20; if (preg_match("/Age:\s*(\d+)/", $text, $matches)) { $message_age = $matches[1]; if ($message_age > $user_age) { // do something if message age is greater than user age } else { // do something if message age is less than or equal to user age } } else { // do something if age is not found in message }

Похожие вопросы

Карта сайта