• 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 get the total hour from starting time to end time in php

Eloquent insert id with sequence next value

Substitute integers and dots with regex [duplicate]

(Cache::lock()) -> get() -- Under what conditions does it return false?

Laravel 5.1 Unknown database type enum requested

PHP | "The requested PHP extension bcmath is missing from your system."

Laravel You requested 1 items, but there are only 0 items available

How to get quarter for future date using Carbon?

How to give apache permission to write to home directory?

protect my blog content

How to Install Composer Require doctrine/dbal

Clear javascript source cache laravel 5.8

PHP Slim Framework request using withAttribute error

PHP SoapClient: set a namespace without prefix

JSON Render Issue in Date Object Laravel and PHP 7.4

About Contact Privacy policy Terms and conditions