You are here: Re: one or two liners apprecaited! « PHP Programming Language « IT news, forums, messages
Re: one or two liners apprecaited!

Posted by Oli Filth on 11/19/63 11:47

laredotornado@zipmail.com said the following on 11/05/2006 15:32:
> Hi, I'm using PHP 4. I have two scalar variables, each containing
> comma separated lists of numbers
>
> $big_list = "1,2,3,4,5,6,7,8";
> $small_list = "5,4,6";
>
> "$small_list" will always contain less elements than "$big_list" and
> all of "$small_list"s numbers will be included in "$big_list". I want
> to get a variable that contains "$big_list" minus "$small_list". In
> the above example, the resulting varaible would contain "1,2,3,7,8".

It's easier to deal with arrays than strings, so convert your lists to
arrays using explode(). Then use some combination of the PHP
array-handling functions; array_diff() might do the job you're after.


--
Oli

 

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

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