• 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

Unable to guess the mime type as no guessers are available Laravel 5.2

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

phpmyadmin : Depends: php-twig (>= 2.9) but 2.6.2-2 is to be installed. WHAT?

Assign output of PHP function to a variable

Login if user is active using Laravel Breeze

How can I access an array/object?

woocommerce change position of price

Target Individual Form Instance/Counter Inside A PHP While Loop

How to convert time from one timezone to another in PHP

Using array_intersect on a multi-dimensional array

Doctrine ORM: Excluding Records Based on Values of Nested Relationships

Laravel SQL query midnight time not showing

Implode array with array of glue strings

Laravel 5.2: Unable to locate factory with name [default]

Spam Filter in Contact Form

About Contact Privacy policy Terms and conditions