james438
01-12-2010, 01:11 AM
here is the example from php.net:
<?php
$stack = array("orange", "banana");
array_push($stack, "apple", "raspberry");
print_r($stack);
?>
What I want is to put the variables "apple" and "raspberry" into a variable or array as in
<?php
$fruit2="apple,raspberry";
$stack = array("orange", "banana");
array_push($stack, $fruit2);
print_r($stack);
?>
While the above works I am not sure as to what the correct syntax should be. Does this look correct? Somehow I figure there should be escaped quotes in $fruit2.
<?php
$stack = array("orange", "banana");
array_push($stack, "apple", "raspberry");
print_r($stack);
?>
What I want is to put the variables "apple" and "raspberry" into a variable or array as in
<?php
$fruit2="apple,raspberry";
$stack = array("orange", "banana");
array_push($stack, $fruit2);
print_r($stack);
?>
While the above works I am not sure as to what the correct syntax should be. Does this look correct? Somehow I figure there should be escaped quotes in $fruit2.