• Categories
    • PHP
    • phpMyAdmin
    • PHPMailer
    • FFMpeg
    • PHPEXcel
    • PHPDoc
    • PHPUnit
    • CakePHP
    • CakePHP 2.0
    • Cake PHP 2.1
    • CakePHP Model
    • Facebook PHP SDK
    • composer-php
    • PHP 7
    • PHP GD
    All Categories
  • About

Why do I have invalid argument supply for foreach in Laravel for json response? [duplicate]

phpjqueryajaxlaravellaravel-5


PHP Snippet 1:

//...
$product  = json_decode($request->product, true);
//...

PHP Snippet 2:

 public function dopayment(Request $request) {

            $input = $request->all();

            $product = json_decode($request->product);


            foreach ($product as $single) {
                # code...

                print_r($single->name);
            }

           print_r($product);
            exit;
        }

PHP Snippet 3:

if (is_array($product ) || is_object($product ))
{
    foreach($product as $arrayItems){
      // Perform x.
    }
}

Related Snippets

Laravel Factory not calling callback 'afterCreating'

How to add class name to an existing tag in php

Symfony autowiring issues since docker update

Get keys from associative array [duplicate]

Which is faster php date functions or carbon?

Send same name multiple checkbox values via ajax

How to install php_imagick on wamp64

How do I call Validator from a namespace with an already existing Validator class

Submitting a form with ajax in Wordpress

Using array_intersect on a multi-dimensional array

I want to display a sweetalert after the inserting of data in my database

Is there an equivalent of DynamoDB on Azure as a PHP session Handler

Correctly determine if date string is a valid date in that format

JSON Render Issue in Date Object Laravel and PHP 7.4

Laravel-fopen: failed to open stream: Permission denied

About Contact Privacy policy Terms and conditions