Re: [PHP4BETA] howto remove key/value...+ SYNTAX Q
| From: | Ly) Vuong | Date: | Tue, 11 Apr 2000 16:36:42 +0000 |
| Subject: | Re: [PHP4BETA] howto remove key/value...+ SYNTAX Q | ||
| References: | 1 2 3 4 | Groups: | php.version4 |
| Request: | Send a blank email to php-version4+get-13394@lists.php.net to get a copy of this message | ||
Hello Teodor,
I have not verify the statement, but I believe the parse error is due
to it's missing the 'if' keyword?
if( (trim($v) == '') && unset($array[$k]) )
;
Cheers,
Ly
---
teo@digiro.net wrote:
>
> Hi Anh!
> On Tue, 11 Apr 2000, Anh (Ly) Vuong wrote:
> >
> > I believe unset() will affect the array's internal pointer. So, it's
> > better to use list(..) and each(..). I would do something similar to
> nope, this:
> $array [0] = " ";
> $array [1] = "foo";
> $array [2] = "\n";
> $array [3] = "bar";
>
> foreach ($array as $k => $v) {
> if (trim($v) == '')
> unset($array[$k]);
> }
> var_dump($array);
>
> outputs:
>
> array(2) {
> [1]=>
> string(3) "foo"
>
> [3]=>
> string(3) "bar"
> }
> which I guess it's the expected result.
>
> SYNTAX Q: why
>
> ( trim($v) == '') && unset ($array[$k]);
>
> in the example above gives a parse error?
>
> -- teodor
>
> --
> PHP 4.0 Beta Mailing List <http://www.php.net/version4/>
> To unsubscribe, e-mail: php4beta-unsubscribe@lists.php.net
> For additional commands, e-mail: php4beta-help@lists.php.net
> To contact the list administrators, e-mail: php4beta-admin@lists.php.net