You are here: Re: help with unset « PHP Programming Language « IT news, forums, messages
Re: help with unset

Posted by Chung Leong on 08/10/06 16:47

Iain Adams wrote:
> Hey i have a loop like so,
>
>
> foreach($users as $user)
> {
> foreach($syncWebUsers as $sync)
> {
> //user already synched
> if($sync['crmid'] == $user[$crmid])
> {
> echo "User Already
> Synched".$user[$crmid];
> unset($user);
> }
> }
> }
>
> Now I wanted this to completely remove the sub array $user from $users
> but when $users remains unchanged when I print_r it. I guess this is to
> do with referencing things. Does anyone know how to combat this problem.

No, not really. Unsetting $user will unset $user, not something in in
$users. To unset the element in $users, you have to specify it. Hence:

foreach($users as $user_index => $user) {
...
unset($users[$user_index]);
...
}

 

Navigation:

[Reply to this 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

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