1

I am trying to use some numbers stored in php session inside the array and displaying them in foreach. For example:

$stored_values = '123,456,789';

Using these values inside array like this:

$array = array($stored_values);

and then trying foreach like:

foreach($array AS $values){
echo $values;
}

But the output is coming as one value for example:

OUTPUT: 123,456,789

Instead of each value separately.

  • 1
    Simply initializing an array with a single comma separated string does not automatically create multiple entries.Try `$array = explode(',', $stored_values);`. Ref: https://www.php.net/manual/function.explode.php – Yoshi Nov 12 '20 at 08:27
  • yes I already tried like this and its working, Thank you :) – Naseemo Advertising Nov 12 '20 at 08:29

0 Answers0