• 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

How to change 'users' auth table and use another instead Laravel

Accessors (Getter) & Mutators (Setter) On a Pivot Table in Laravel

Laravel passport auth token not working after moving to different server

laravel 5.6 bulk inserting json data

Laravel display validation error

How to implement placeholder in a php file for moodle plugin?

Laravel relationship belongsToMany with composite primary keys

Update Order custom Field value with WooCommerce REST API

Cut an arabic string

oauth-private.key does not exist or is not readable

Symfony 4: "Autowire: you should configure its value explicitly."

How to set time with DateTime modify?

Sum array values of a column within each column of an array with 3 levels

Laravel Unresolvable dependency resolving [Parameter #0 [ <required> $method ]] in class GuzzleHttpPsr7Request

Can't call javascript alert alertify library from PHP

About Contact Privacy policy Terms and conditions