• 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

enroll_table three field fetch to payment form to create payment field in laravel 5.5

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

How to create a individual template for page or post in custom plugin?

set mail driver dynamically from database for different email in notification

Laravel 8: Array to string conversion while calling route:list

HTML + PHP + PHPMAILER

ldap is missing from system when installing adldap2 in laravel

Laravel lang slug in url

Cannot connect to own websocket server when on secured domain

array_key_exists(): The first argument should be either a string or an integer

How to change the app environment at run time?

Limit login attempts in Laravel 5.7

Xdebug in Laravel is not working with VSCode

Laravel set default language not working

merging two arrays with specified index

About Contact Privacy policy Terms and conditions