Skip to content
Advertisement

PHP Query – Check string character

JavaScript

Above code is working where it able to check if the “variable” is starting with ‘ax’, but what if i wanted to check “multiple” different validation ?

for example : ‘ax’,’ab’,’ac’ ? Without creating multiple if statement

Advertisement

Answer

You can use array to store your keywords and then use in_array() if you want to avoid multiple if statements.

JavaScript

References: in_array — Checks if a value exists in an array

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement