Skip to content
Advertisement

use LIKE with array in laravel

I am trying to get a list of registered users that are on the contact list of a user. Since many users save phone numbers without the international prefix so I can’t use whereIn. I am using the last 7 digits of the user’s contact phone numbers to compare with phone numbers of users in the database to return registered users on a user’s contact.

my code looks like this

JavaScript

My $numbers array looks like this

JavaScript

but I keep getting an empty array as response. What am I doing wrong

Advertisement

Answer

You’re $numbers variable is an array with one string of comma delimited numbers, you should be exploding them, not wrapping in an array, try this instead:

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