I can get this to work:

$counter = 2;
$src = ",'new[item" . $counter . "]'";
echo $src;

But, not this:

$counter = 2;
$src = ",'$new[item" . $counter . "]'";
echo $src;

Where $new has already been defined as an array.

What do you think is the problem?

Turns out, the brackets needed to be closed. This works:

$index = 'item' . $counter;
$src = $src . ", '$new[$index]'";


This didn't work:


$src = ",'$new[item" . $counter . "]'";


Thanks,

Niche

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.