'PHP filter through string

$string = "this is a string";

if ($string.split(" ").includes "is string") {
echo "Included";
}

I want to separate query by spaces, and see if string includes all separated parts.

And if anybody has the code for this question.



Solution 1:[1]

simple code will be like this

<?php

$string_var = ['is','string'];
$string_to_check = 'this is a string';

$to_check = explode(' ',$string_to_check);

print_r($to_check);

foreach($to_check as $string)
{
    if(in_array($string,$string_var))
    {
        echo "Found: ".$string."\n";
    }
}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 zimorok