dimanche 3 juillet 2016

Convert javascript array to php array in laravel

Written with StackEdit.

Hi, i am passing an ajax call to delete some user data, and this data is passed in an hidden input, I want to convert it to a php array to be able to do a foreach loop around it how can i achieve that.

THE VALUES IT OUTPUT IN JS ""49,51,53,54""

THE PHP CODE

public function usersDelete(){

    $data = Input::all();
    $checkedUsers = Input::get('checkedUsers'); // data is an array

    foreach ($checkedUsers as $checkedUser) {

        User::where('id', '=', $checkedUser)->first()->delete();
    }
}

the problem is that it loops only one the first array value in the set of arrays.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire