Robert Cummings wrote:

Is there a reason you're using a comma delimited string? I would
recommend using an array instead:

<?php
session_name( 'CCLTrolley' );
session_start();
// Initialize the trolley.
if( !isset( $_SESSION['TrolleyContents'] ) )
{
   $_SESSION['TrolleyContents'] = array();
}
// Add new entry.
if( isset( $_POST['RNum'] ) )
{
   $_SESSION['TrolleyContents'][$_POST['RNum']] = $_POST['RNum'];
}
echo implode( ',', $_SESSION['TrolleyContents'] );
print_r($_SESSION);
?>

Cheers,
Rob.

Hi,
Still absorbing this array stuff :).
I'm getting this error. And when RNum = 1 or = 16 or = 116, it only registers '1', or whatever the first digit is.

Warning: Bad arguments to implode() in /var/.../printtrolley.php on line 14
Array ( [TrolleyContents] => 1 3 4 4 5 6 )

I was expecting to see soemthing like:

TrolleyContents[16]
TrolleyContents[32]
TrolleyContents[45]
TrolleyContents[48]
TrolleyContents[55]
TrolleyContents[116]

if I have done my homework, since last night ;), correctly?

The manual example says:
<?php
$array = array('lastname', 'email', 'phone');
$comma_separated = implode(",", $array);
echo $comma_separated; // lastname,email,phone
?>

What is my correct seperator? And why does only one digit get registered?

Thanks,
John

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to