• 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

(Cache::lock()) -> get() -- Under what conditions does it return false?

Access denied for user 'homestead'@'localhost' (using password: YES)

Laravel eloquent update record without loading from database

ldap is missing from system when installing adldap2 in laravel

Submitting a form with ajax in Wordpress

Unable to create lockable file - Laravel 8 & PHP 8

wordpress : How to specify the cause "This site can’t be reached"

Detect if PHP session exists

Add rows to Single product Additional information table in WooCommerce 3.6

Display Brand Name Above Product Title in Woocommerce Cart, Checkout Page, Orders and Email Notification

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

Testing subscription renewals on Stripe

How to identify whether webp image is static or animated?

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

virtctl works when executed via command line but not from php exec()

About Contact Privacy policy Terms and conditions