Reply to Re: Why does this foreach loop fail to work?

Your name:

Reply:


Posted by Tim Roberts on 09/19/06 07:18

"comp.lang.php" <phillip.s.powell@gmail.com> wrote:
>
>[PHP]
> $array = array($firstOrderByFieldIfClause, $groupByClause,
>$orderByClause);
> array_walk($array, create_function('&$a', '$a = substr($a, 0,
>strrpos(trim($a), ",")); if ($a) $a = ", $a";'));
> print_r("firstOrderByFieldIfClause = $firstOrderByFieldIfClause and
>groupByClause = $groupByClause and orderByClause = $orderByClause<P>");
>[/PHP]
>
>Upon execution the fields within $array are never changed (verified by
>checking code), and I don't understand why.

It certainly does. Try "var_dump($array);", and you'll see that all three
strings were changed.

Your mistake is in thinking that changes to $array(0) will also affect
$firstOrderByFieldIfClause.

The array constructor makes three new strings.
--
- Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация