0

I'm tring to create an array of string but I can't do this if I use a variable.

$dir_photo="./Foto_NEW/";
$photo= array($dir_photo+"DSCN2507.JPG",$dir_photo+"IMG_0054.JPG",$dir_photo+"IMG_0058.JPG");

The result is 0 0 0.

rpax
  • 4,363
  • 7
  • 31
  • 55
Stefano Maglione
  • 3,695
  • 10
  • 43
  • 85

3 Answers3

4

+ is the concatenation operator in Javascript, but in PHP it's the period . So what you need is this:

$photo= array($dir_photo."DSCN2507.JPG",$dir_photo."IMG_0054.JPG",$dir_photo."IMG_0058.JPG");
larsAnders
  • 3,807
  • 1
  • 13
  • 19
2

You need to replace the + with a .

$dir_photo."DSCN2507.JPG"

+ is used in javascript, . is used in php

Kevin Lynch
  • 23,813
  • 2
  • 34
  • 37
0

Try this:

$dir_photo="./Foto_NEW/";
$photo= array($dir_photo."DSCN2507.JPG",$dir_photo."IMG_0054.JPG",$dir_photo."IMG_0058.JPG");

You need to use . instead of + to concatenate strings.