how to make a array path

Previous Topic Next Topic
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

how to make a array path

first thank for all CakePHP. I learned a lot of thing when i work with your framework and I hope I can be useful one day

I am writing this little code to cycle through the array and I think that it can be useful


function set($path,$value,&$point){
= explode('.',$path);
= strstr($path,'.');
= substr($path,-strlen($path)+1);
if( !isset($point[$aPath[0]]) || !is_array($point[$aPath[0]])){
[$aPath[0]] = [];
return set($path,$value,$point[$aPath[0]]);
[$aPath[0]] = $value;
return true;

= [];
set('','it works',$myArray);
set('',['bar' =>'it works'],$myArray);
set('a.b.c.d.e.f','it works',$myArray);

Like Us on FaceBook
Find us on Twitter

You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at
For more options, visit