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,468
  • 7
  • 33
  • 57
Stefano Maglione
  • 3,946
  • 11
  • 49
  • 96

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,813
  • 1
  • 15
  • 19
2

You need to replace the + with a .

$dir_photo."DSCN2507.JPG"

+ is used in javascript, . is used in php

Kevin Lynch
  • 24,427
  • 3
  • 36
  • 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.