• 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 csrf token mismatch for ajax POST Request

how to see if database exists with PDO [duplicate]

PhP how to calculate moments with variables rows

Find out the name of the last script that included the current one

Fatal error: Array callback has to contain indices 0 and 1

php script to delete files older than 24 hrs, deletes all files

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

How To Access A Column In M-M Relationship Table In Laravel

Convert every two values of an associative array into key-value pairs

Generate random username based on full name php

PHP how to detect if running on arm64 cpu?

How do I set the maximum php memory limit

Issue saving card for customer

Comma separated list from array with "and" before last element

How can I pass the list to the component variable in Laravel?

About Contact Privacy policy Terms and conditions