• 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

Utf8 encoding issue with Laravel

Composer Warning: openssl extension is missing. How to enable in WAMP

Laravel after login Two factor not working

How to add automatically collapse/expand in content wordpress (single.php)?

how to remove %20 in the url in php

how do i retrieve and display the alt text of an image in wordpress?

Laravel Multi-language routes without prefix

Ajax GET request fails in laravel 8

How to properly start Laravel 8 with Bootstrap & authentication

Move a child array to parent array and change parent/child name

Can I use a WooCommerce function without any WooCommerce page?

Ajax GET request fails in laravel 8

Unable to create lockable file - Laravel 8 & PHP 8

How to disable only_full_group_by option in Laravel

Implode columnar values between two arrays into a flat array of concatenated strings

About Contact Privacy policy Terms and conditions