implode explode

Hi,

Iwas just testing out how the explode and implode functions work. i started off converting an array ($numbers) into a string, via a new variable ($num_string). worked fine. I then tried to explode the newly created string back into an array and i get.
! ) Notice: Array to string conversion in C:\wamp\www\sandbox\array functions.php on line 33.
here’s the code.
Implode: <?php echo $num_string = implode(' . ', $numbers); ?>

<?php echo gettype($num_string);?>

Explode: <?php echo $num_exp = explode(' . ', $num_string); ?>

<?php echo gettype($num_exp);?>

Any idea’s?

Thanks

I’m guessing this is line 33?

[php]Explode: <?php echo $num_exp = explode(' . ', $num_string); ?>
[/php]

You are echoing an array. It tends not to like that. Use this instead:

[php]Explode: <?php $num_exp = explode(' . ', $num_string); ?>

<?php echo "
";
print_r( $num_exp );
echo "
"; echo gettype($num_exp);?>
[/php]

yeah, that worked :slight_smile: thank you

Sponsor our Newsletter | Privacy Policy | Terms of Service