• 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

XML to CSV with PHP converter [problem with images grabing]

What is the difference between client-side and server-side programming?

Edit XML in HTML form and submit to self

How to fix bootstrap multiselect search data using ajax

Laravel phpunit test failing authorization

Required field only if another field has a value, must be empty otherwise

renameColumn migration fails for existing column with columns does not exist error

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

Implode array with array of glue strings

How to convert binary string to normal string in php

Insert And Retrieve Data in MySQL with $.post Noob Question

phpunit - testing is painfully slow

Add customer email and phone in "Order" column to admin orders list on Woocommerce

Store multiple fields in JSON column (Nova CMS)

IlluminateDatabaseQueryException could not find driver [duplicate]

About Contact Privacy policy Terms and conditions