-1

Hi guys I am trying to get the following code below to work but I got a parse error: syntax error, unexpected '"'

$product .= "$item_id-""$length-""$Category-".$each_item['quantity'].","; 

Basically it is meant to show something like this. 1-12 size-blue-13 the ","

Jessica
  • 61
  • 8
  • you forgot to add a dot between "$item_id-" and "$length-" and also "$length-" and "$Category-" try this: $product .= "$item_id-"."$length-"."$Category-".$each_item['quantity'].","; – Barış Akkurt Aug 04 '13 at 20:01

2 Answers2

2

With strings you can use braces:

$product .= "${item_id}-${length}-${Category}-${each_item['quantity']},"; 
Andrey Volk
  • 3,513
  • 2
  • 17
  • 29
0

PHP variable interpolation vs concatenation


The correct syntax - $product .= "${item_id}-"."${length}-"."${Category}-".$each_item['quantity'].",";

Community
  • 1
  • 1
Patt Mehta
  • 4,110
  • 1
  • 23
  • 47