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

2009-06-08 Thread Ford, Mike
On , nit...@binnun.co.il advised:

 
 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
 

That looks like severe overkill -- recursion *and* an implode/explode
per directory??

I'd write it something like this:

  function convert($pseudo_path)
  {
 $pseudo_dirs = explode('/', $pseudo_path);
 $result = array_pop($pseudo_dirs);
 for ($i=count($pseudo_dirs-1; $i=0; --$i):
$result = array($pseudo_dirs[$i] = $result);
 endfor;

 return $result;
  }

This is completely off the top of my head and untested, so no guarantees
provided ;)

Cheers!

Mike

 --
Mike Ford,  Electronic Information Developer,
C507, Leeds Metropolitan University, Civic Quarter Campus, 
Woodhouse Lane, LEEDS,  LS1 3HE,  United Kingdom
Email: m.f...@leedsmet.ac.uk
Tel: +44 113 812 4730


To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



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

2009-06-08 Thread Nitsan Bin-Nun
I wrote that function in a couple of minutes, haven't dedicated much time to
think of the efficiency of it, you are definitely right but I'm pretty much
sure that for 10 segments URLs you won't feel the difference. If you want I
can benchmark it.

Thanks for the heads up.

--
Nitsan

On Mon, Jun 8, 2009 at 3:27 PM, Ford, Mike m.f...@leedsmet.ac.uk wrote:

 On , nit...@binnun.co.il advised:


  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
 

 That looks like severe overkill -- recursion *and* an implode/explode
 per directory??

 I'd write it something like this:

  function convert($pseudo_path)
  {
 $pseudo_dirs = explode('/', $pseudo_path);
 $result = array_pop($pseudo_dirs);
 for ($i=count($pseudo_dirs-1; $i=0; --$i):
$result = array($pseudo_dirs[$i] = $result);
 endfor;

 return $result;
  }

 This is completely off the top of my head and untested, so no guarantees
 provided ;)

 Cheers!

 Mike

  --
 Mike Ford,  Electronic Information Developer,
 C507, Leeds Metropolitan University, Civic Quarter Campus,
 Woodhouse Lane, LEEDS,  LS1 3HE,  United Kingdom
 Email: m.f...@leedsmet.ac.uk
 Tel: +44 113 812 4730


 To view the terms under which this email is distributed, please go to
 http://disclaimer.leedsmet.ac.uk/email.htm

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] alpha/beta/gamma TO $var['alpha']['beta'] = 'gamma'

2009-06-07 Thread דניאל דנון
I have encountered a problem when trying to turn

-- 
Use ROT26 for best security


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

2009-06-07 Thread Angus Mann

??? Huh  ???


- Original Message - 
From: דניאל דנון danondan...@gmail.com

To: PHP General List php-general@lists.php.net
Sent: Sunday, June 07, 2009 8:11 PM
Subject: [PHP] 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



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

2009-06-07 Thread Nitsan Bin-Nun
I think that he is talking about uri rewriting :O

On Sun, Jun 7, 2009 at 2:04 PM, Angus Mann angusm...@pobox.com wrote:

 ??? Huh  ???


 - Original Message - From: דניאל דנון danondan...@gmail.com
 To: PHP General List php-general@lists.php.net
 Sent: Sunday, June 07, 2009 8:11 PM
 Subject: [PHP] 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




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

2009-06-07 Thread shahrzad khorrami
:D


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

2009-06-07 Thread דניאל דנון
if I send half messages tell me, since gmail is slow so sometimes I
click 10 times on the send...
On Sun, Jun 7, 2009 at 2:33 PM, Nitsan Bin-Nunnitsa...@gmail.com wrote:
 I think that he is talking about uri rewriting :O

 On Sun, Jun 7, 2009 at 2:04 PM, Angus Mann angusm...@pobox.com wrote:

 ??? Huh  ???


 - Original Message - From: דניאל דנון danondan...@gmail.com
 To: PHP General List php-general@lists.php.net
 Sent: Sunday, June 07, 2009 8:11 PM
 Subject: [PHP] 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

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



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

2009-06-07 Thread Nitsan Bin-Nun
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, דניאל דנון danondan...@gmail.com 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-Nunnitsa...@gmail.com wrote:
  I think that he is talking about uri rewriting :O
 
  On Sun, Jun 7, 2009 at 2:04 PM, Angus Mann angusm...@pobox.com wrote:
 
  ??? Huh  ???
 
 
  - Original Message - From: דניאל דנון danondan...@gmail.com
  To: PHP General List php-general@lists.php.net
  Sent: Sunday, June 07, 2009 8:11 PM
  Subject: [PHP] 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



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

2009-06-07 Thread דניאל דנון
problem is number of / is unknown.
It can be alpha/beta
alpha/beta/gamma
alpha/beta/gamma/delta
...

(here's a copy to the nice list =] )

On Sun, Jun 7, 2009 at 2:53 PM, Nitsan Bin-Nunnitsa...@gmail.com 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, דניאל דנון danondan...@gmail.com 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-Nunnitsa...@gmail.com wrote:
  I think that he is talking about uri rewriting :O
 
  On Sun, Jun 7, 2009 at 2:04 PM, Angus Mann angusm...@pobox.com wrote:
 
  ??? Huh  ???
 
 
  - Original Message - From: דניאל דנון danondan...@gmail.com
  To: PHP General List php-general@lists.php.net
  Sent: Sunday, June 07, 2009 8:11 PM
  Subject: [PHP] 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

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



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

2009-06-07 Thread Nitsan Bin-Nun
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, דניאל דנון danondan...@gmail.com 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-Nunnitsa...@gmail.com 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, דניאל דנון danondan...@gmail.com
 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-Nunnitsa...@gmail.com
 wrote:
   I think that he is talking about uri rewriting :O
  
   On Sun, Jun 7, 2009 at 2:04 PM, Angus Mann angusm...@pobox.com
 wrote:
  
   ??? Huh  ???
  
  
   - Original Message - From: דניאל דנון 
 danondan...@gmail.com
   To: PHP General List php-general@lists.php.net
   Sent: Sunday, June 07, 2009 8:11 PM
   Subject: [PHP] 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



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

2009-06-07 Thread דניאל דנון
$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-Nunnitsa...@gmail.com 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, דניאל דנון danondan...@gmail.com 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-Nunnitsa...@gmail.com 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, דניאל דנון danondan...@gmail.com
  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-Nunnitsa...@gmail.com
  wrote:
   I think that he is talking about uri rewriting :O
  
   On Sun, Jun 7, 2009 at 2:04 PM, Angus Mann angusm...@pobox.com
   wrote:
  
   ??? Huh  ???
  
  
   - Original Message - From: דניאל דנון
   danondan...@gmail.com
   To: PHP General List php-general@lists.php.net
   Sent: Sunday, June 07, 2009 8:11 PM
   Subject: [PHP] 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

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



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

2009-06-07 Thread Nitsan Bin-Nun
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, דניאל דנון danondan...@gmail.com 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-Nunnitsa...@gmail.com 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, דניאל דנון danondan...@gmail.com
 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-Nunnitsa...@gmail.com
 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, דניאל דנון danondan...@gmail.com
   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-Nunnitsa...@gmail.com
   wrote:
I think that he is talking about uri rewriting :O
   
On Sun, Jun 7, 2009 at 2:04 PM, Angus Mann angusm...@pobox.com
wrote:
   
??? Huh  ???
   
   
- Original Message - From: דניאל דנון
danondan...@gmail.com
To: PHP General List php-general@lists.php.net
Sent: Sunday, June 07, 2009 8:11 PM
Subject: [PHP] 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