arrays - PHP > Returning allowed paths -


this question has answer here:

i asked question published little confusing , therefore proberbly not answered. try again example, if it's fine.

there original array's url's 1 in example 1 , 2. every last folder of each element of original array folder user has right view.

example 1

array( 'a' 'a/b/c' 'a/b/c/d/e' 'a/y' 'b/z' 'b/z/q ) 

i 2 array's like:

array['short']( 'a/c/e' 'a/y' 'z/q' )  array['full']( 'a/b/c/d/e' 'a/y' 'b/z/q' ) 

example 2

array( 'projects/projecta/books' 'projects/projecta/books/cooking/book1' 'projects/projecta/walls/wall' 'projects/projectx/walls/wall' 'projects/projectz/' 'projects/projectz/wood/cheese/bacon' ) 

i 2 array's like:

array['short']( 'books/book1' 'wall' 'wall' 'projectz/bacon' )  array['full']( 'projects/projecta/books/cooking/book1' 'projects/projecta/walls/wall' 'projects/projectx/walls/wall' 'projects/projectz/wood/cheese/bacon' ) 

@adyson asks question. you've told no rules governing should removed. if assume you're looking remove first 2 elements of each array item, can...

$original_array = array( 'projects/projecta/books', 'projects/projecta/books/cooking/book1', 'projects/projecta/walls/wall', 'projects/projectx/walls/wall', 'projects/projectz/', 'projects/projectz/wood/cheese/bacon' );  $new_array = array(); $new_array['full'] = array(); $new_array['short'] = array();  foreach($original_array $full_url){     $tmp = explode("/",$full_url);     array_shift($tmp);     array_shift($tmp);     if(count($tmp)>1){         array_push($new_array['full'], $full_url);         array_push($new_array['short'], implode("/",$tmp));     } }  print_r($new_array); 

however, i'm making huge assumption you're trying , why you're trying it. therefore, wrong. why @adyson asking clarify rules.


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -