Answer the question
In order to leave comments, you need to log in
How can I find out if a variable contains one of the listed characters?
Hello.
There was such task
there is a variable, let's say
$a = ''Hello moto;
And you need to find out if there are characters h and t in this variable.
How can this be implemented? what function would you recommend to use for this?
And how to list all characters to be searched?
Answer the question
In order to leave comments, you need to log in
$re = '/[eps]/m';
$str = 'help me please';
preg_match_all($re, $str, $matches, PREG_SET_ORDER, 0);
// Print the entire match result
var_dump($matches);
It should have been written in the book you are reading
https://www.php.net/manual/en/function.strrpos.php
If the task is this:
How can I find out if a variable contains one of the listed characters?
$a = ''Hello moto;
And you need to find out if there are characters h and t in this variable.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question