I'm trying to learn PHP on my own just by watching videos and reading blogs. I won't become a pro, I'm just a hobbyist. So I'm trying to code something but I got to a dead end.
So I have a string, let's say the string has some numbers f.e. 100, 2000, 3000. Using the explode method I convert the string to an array. Now I have a variable f.e.
$var= 50;
I want to see if $var is equal to the first or the third element of the array;
<?php
$str = " 100, 2000, 3000";
$fevArr = explode(",", $str);
$var = 50;
if ($var == $fevArr['0'] or $var == $fevArr['2'] ) {
echo "It is";
} else {
echo "It is not";
}
?>
However I might have a lot of numbers in the string and I may want to check if $var is eaqual to many of them (say to the 1th, 10th, 20th, 101th, 300th ect). So I wonder if there is a way to make soemthing like this:
if ($var == $fevArr['0', '9', '19',]) { ....
In other words if there is a way to select several array elements at once.