0

I'm a beginner in Laravel, so my problem is that I want to display the data that an array contains. It's been a week that I try to solve it personally, but I do not get what I want.

This is a part of my controller:

  if ( !empty ( $nbrrowsol ) ) {
            for ($i=1; $i <=$nbrrowsol ; $i++) {
                # Code...
                $clients = DB::table('clients')->where('nom',$request->get('nomclient'))->first();
                $commercial=DB::table('commercials')->where('name',$request->get('commercial'))->first();

                $commande[] = array(
            'nom_client' => $request->get('nomclient')[$i],
            'organisme' => $request->get('organisme')[$i],
            'adresse' => $request->get('adresse')[$i],
            'email' => $request->get('email')[$i],
            'tel1' => $request->get('tel')[$i],
            'tel2' => $request->get('tel2')[$i],
            'fax' => $request->get('fax')[$i],
            'commercial' => $request->get('commercial')[$i],
            'date_reception' => $request->get('datereception')[$i],
            'date_prelevement' => $request->get('dateprelev')[$i],
            'saved_by' => $request->get('savedby')[$i],
            'code' => $request->get('codesol'.$i)[$i],
            'nature' => $request->get('naturesol'.$i)[$i]
                );
            }
  dd($commande);

        }

This is what I got in the console, but I didn't get the value:

Enter image description here

8
  • Can you provide what is $nbrrowsol @Oussama Commented Jun 24, 2019 at 12:36
  • $nbrrowsol=$request->get('nbrrowsol'); Commented Jun 24, 2019 at 12:46
  • So what is data inside $nbrrowsol is that array or what? Just show dd($nbrrowsol). And also give dd($request->all()). Because you go through string in your for. Just give data from request... Commented Jun 24, 2019 at 12:48
  • $nbrrowsol contains a number Commented Jun 24, 2019 at 13:28
  • array:36 [▼ "_token" => "5pBe3cwHPNDkWq5im41FGVGV1PJDGKHdUoANvAkF7pz" "nomclient" => "client1" "organisme" => "ets" "adresse" => "stock" "email" => "[email protected]" "tel" => "+6456789" "tel2" => "+6864567" "fax" => "+3456789" "commercial" => "jamal" "datereception" => "2019-06-11" "dateprelev" => "2019-06-05" "savedby" => "responsable" "nbrrowsol" => "2" "codesol1" => "SOL201948" "naturesol1" => "SOL" "codesol2" => "SOL201949" "naturesol2" => "SOL" ] Commented Jun 24, 2019 at 13:47

1 Answer 1

2

You can use the below syntax for printing the data:

 echo '<pre>';
 print_r($commande);
 die;

Or:

echo '<pre>';
print_r($commande->toArray());
die;
Sign up to request clarification or add additional context in comments.

8 Comments

not working, itried that but i get this error Call to a member function toArray() on array
yes i tried it, but get the same result like in the picture on top
share the picture once again just because dd and print_r is working differently.
Pass request data here
i post a picture that contains result of print_r($commande); in answer
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.