Its a good way of solving the problem Mustafa. Except that your code has a minor problem.
Assuming that you are searching for one table in many, there will be many false matches and only one true match.
Thus your code will always return a fail, unless there is only one table which is the correct table.
It would be better to do it the other way around, using $passed instead of $failed and setting $passed to true when you find the correct table. Of course initiate $passed as false.
Or better still stop the loop when the table is found, unless your searching for more than one table.
David