jeudi 19 décembre 2019

How to get only specific input from Laravel request?

I have input request from controller as below code.

   public function CreateSave(Request $request){
       return $request;
   }

Below are printed inputs request.

 {
    _token: "jf9SQUP48wrPz9LBT8ItZ76UHOc4lD6ot3HrF0bB",
    hn: null,
    prefix: "1",
    name: john,
    lastname: doe,
    room: "1",
    custom_1154: "100",
    custom_51741: "99660"
 }

But, I would like to get only input contain specific string 'custom_'. So result should be like this.

 {
    custom_1154: "100",
    custom_51741: "99660"
 }

I may use foreach loop but I'm not sure other smart way capable. Any advise or guidance would be greatly appreciated, Thanks.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire