You are here: Re: PHP Cli arguments « PHP Programming Language « IT news, forums, messages
Re: PHP Cli arguments

Posted by The87Boy on 12/28/07 16:13

On Dec 28, 4:38 pm, Csaba Gabor <dans...@gmail.com> wrote:
> On Dec 28, 6:21 am, The87Boy <the87...@gmail.com> wrote:
>
> > I am trying to make a PHP Cli program, but there is something I do not
> > know what to do
>
> > If we take an example:
> > php5 test.php --add Hello World I am great --delete World great --sort
> > test.txt
>
> > I want to have an array with the commands, that look like this:
> > Array (
> > [--add] => Array('Hello', 'World', 'I', 'am', 'great'),
> > [--delete] => Array('World', 'great'),
> > ['--sort'] => Array()
> > );
>
> How about this (untested):
>
> $aArgs = array();
> foreach ($argv as $arg) {
> if (substr($arg,0,2)=="--") $aArgs[$a=$arg] = array();
> else $aArgs[$a][] = $arg; }

You are right, but I thought, I could validate if the argument
starting with - or --, was in the array with arguments

 

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

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