Re: Splice problem
| From: | CPT John W. Holmes | Date: | Thu, 18 Sep 2003 21:07:22 +0000 |
| Subject: | Re: Splice problem | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-163058@lists.php.net to get a copy of this message | ||
From: "Stevie D Peele" <sdp2006@juno.com>
> My problem is that I am splicing an array and then echoing the array
> [code]
> <?php
> $input = array("red", "green", "blue", "yellow");
> array_splice($input, 2);
>
> echo $input;
> ?>
> [/code]
>
> and all that is echoed is "Array." I want red green to be echoed.
That's because $input IS an array.
Try just displaying $input[0] and $input[1] for "red" and "green".
You also need to assign the result of array_splice() to something...
$new_array = array_splice($input,2);
Maybe you should explain exactly what you're trying to accomplish with all
of this. There may be a better method.
---John Holmes...