• 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 submit a form when page loads using JavaScript?

Sliders in Laravel

How to create laravel storage symbolic link for production or sub domain system?

How to change the app environment at run time?

Unable to get password for the instance created from AMI

How to get the total hour from starting time to end time in php

Laravel 8 factory state afterCreating

Lexik JWT authentication problem "Invalid credentials"

JSON Render Issue in Date Object Laravel and PHP 7.4

How can I solve "laravel/horizon v1.1.0 requires ext-pcntl * -> the requested PHP extension pcntl is missing from your system"?

Reload parent page after submit in iframe

Show date difference as "20" instead of "20 years ago"

How to get array values using foreach in laravel

Laravel update hasMany relationship using saveMany

PHP: Convert any string to UTF-8 without knowing the original character set, or at least try

About Contact Privacy policy Terms and conditions