I have the following list (example codes, variable $code_name): "A125" "B120" "C105"
And an array ($codes_list) with a lot of codes but also with some extra words in them: "A125 NameA" "B8800 Ko" "B120 Name Bc" "D3030"
Within a for loop I can check if any of the values ($code_name) from the above list exists in the array.
if (in_array($code_name, $codes_list))
{
echo "Do nothing<br/>";
} else {
echo "Code is not in the list, create new one in DB: ".$code_name."<br/>";
}
The problem as I said is that the $code_name contains only the "A125". But in the array list some additional text is added there "A125 NameA". So the result won't be what I want it to be.
If code name ALREADY EXISTS in the list (like A125,B120 for example) then do nothing. If it doesn't exist (C105) then create one in DB.
But what I'm trying to achieve is to check whether the $code_name LIKE%% in $codes_list array. So I'm trying to find a similar function to the mysql one.
Is that possible?
if (in_array(LIKE%'.$code_name.'%, $codes_list))
Thanks for the help