Re: alpha/beta/gamma TO $var['alpha']['beta'] = 'gamma'

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The final code:

<?php
>
> echo '<pre>';
> echo var_dump(nitsanush("alpha/beta"));
> echo "\n";
> echo var_dump(nitsanush("alpha/beta/gamma"));
> echo "\n";
> echo var_dump(nitsanush("alpha/beta/gamma/delta"));
> echo "\n";
> echo var_dump(nitsanush("alpha/beta/gamma/delta/nitsan"));
> echo "\n";
> echo var_dump(nitsanush("alpha/beta/gamma/delta/nitsan/daniel"));
> echo "\n";
> echo '</pre>';
>
> function nitsanush($v)
> {
>     $a = explode("/", $v);
>     if (sizeof($a) > 2)
>     {
>         $b = $a;
>         unset($b[0]);
>         return array($a[0] => nitsanush(implode("/", $b)));
>     }
>     else
>     {
>         return array($a[0] => $a[1]);
>     }
> }
>
> // eof
>

--
Nitsan

On Sun, Jun 7, 2009 at 3:17 PM, דניאל דנון <danondaniel@xxxxxxxxx> wrote:

> $v['alpha']['beta']['gamma'] = 'delta';
>
> (or)
>
> array(
> "alpha" => array("beta" => array("gamma" => "delta")))
> );
>
>
> (sorry, here is a copy to the nice list)
>
> On Sun, Jun 7, 2009 at 3:00 PM, Nitsan Bin-Nun<nitsanbn@xxxxxxxxx> wrote:
> > Can you give me an example of the output in case that the input is
> > "alpha/beta/gamma/delta" please?
> >
> > On Sun, Jun 7, 2009 at 2:56 PM, דניאל דנון <danondaniel@xxxxxxxxx>
> wrote:
> >>
> >> problem is number of "/" is unknown.
> >> It can be alpha/beta
> >> alpha/beta/gamma
> >> alpha/beta/gamma/delta
> >> ...
> >>
> >> On Sun, Jun 7, 2009 at 2:53 PM, Nitsan Bin-Nun<nitsanbn@xxxxxxxxx>
> wrote:
> >> > Don't forget to send a copy to the list ;)
> >> >
> >> > Regarding your function, I'm writing it right now, it would probably
> >> > have
> >> > some issues but I think that it would work:
> >> >
> >> > function somefunction($v)
> >> > {
> >> >     preg_match("#^([^/]+)/([^/]+)/(.+)$#", $v, $m);
> >> >     return array($m[1] => array($m[2] => $m[3]));
> >> > }
> >> >
> >> >
> >> > HTH,
> >> > Nitsan
> >> >
> >> > On Sun, Jun 7, 2009 at 2:36 PM, דניאל דנון <danondaniel@xxxxxxxxx>
> >> > wrote:
> >> >>
> >> >> its related to that but I'm building a kind of "supposed" urls for
> >> >> certain things... Its complicated to explain,
> >> >> But I need to turn
> >> >> print_r($var); // alpha/beta/gamma
> >> >>
> >> >> $var = somefunction($var);
> >> >>
> >> >> print_r($var); // array("alpha" => array("beta" => "gamma"))
> >> >>
> >> >>
> >> >> On Sun, Jun 7, 2009 at 2:33 PM, Nitsan Bin-Nun<nitsanbn@xxxxxxxxx>
> >> >> wrote:
> >> >> > I think that he is talking about uri rewriting :O
> >> >> >
> >> >> > On Sun, Jun 7, 2009 at 2:04 PM, Angus Mann <angusmann@xxxxxxxxx>
> >> >> > wrote:
> >> >> >
> >> >> >> ??? Huh  ???
> >> >> >>
> >> >> >>
> >> >> >> ----- Original Message ----- From: "דניאל דנון"
> >> >> >> <danondaniel@xxxxxxxxx>
> >> >> >> To: "PHP General List" <php-general@xxxxxxxxxxxxx>
> >> >> >> Sent: Sunday, June 07, 2009 8:11 PM
> >> >> >> Subject:  alpha/beta/gamma TO $var['alpha']['beta'] = 'gamma'
> >> >> >>
> >> >> >>
> >> >> >>
> >> >> >>  I have encountered a problem when trying to turn
> >> >> >>>
> >> >> >>> --
> >> >> >>> Use ROT26 for best security
> >> >> >>>
> >> >> >>>
> >> >> >>
> >> >> >> --
> >> >> >> PHP General Mailing List (http://www.php.net/)
> >> >> >> To unsubscribe, visit: http://www.php.net/unsub.php
> >> >> >>
> >> >> >>
> >> >> >
> >> >>
> >> >>
> >> >>
> >> >> --
> >> >> Use ROT26 for best security
> >> >
> >> >
> >>
> >>
> >>
> >> --
> >> Use ROT26 for best security
> >
> >
>
>
>
> --
> Use ROT26 for best security
>

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux