• 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

Send Outlook 2010 email using PHP

Pass an image through AJAX [duplicate]

Laravel csrf token mismatch for ajax POST Request

Can I use a WooCommerce function without any WooCommerce page?

Assets not referencing to public folder (Laravel)

Laravel dosen't connect with Oracle

How to average columns of data from multiple, flat arrays?

Pass an image through AJAX [duplicate]

Add Metadata, headers (Expires, CacheControl) to a file uploaded to Amazon S3 using the Laravel 5.0 Storage facade

Combine multiple columns into an array as one of the key in a results set

Cant seem to get the Pagination to work on my WooCommerce REST API application?

Limit of log line written to Apache Errorlog from mod php error_log

Target Individual Form Instance/Counter Inside A PHP While Loop

Message: Set sys_temp_dir in your php.ini after installed composer

PHP: How to quickly split a key=value file into associative array

About Contact Privacy policy Terms and conditions