User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 373,933 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,157 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting

Dynamic Declaration of Arrays Keys

Join Date: Jul 2007
Posts: 9
Reputation: CMCDragonkai is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
CMCDragonkai CMCDragonkai is offline Offline
Newbie Poster

Re: Dynamic Declaration of Arrays Keys

  #5  
Feb 18th, 2008
I recently rewrote the function, to this. It works to do what I want it to do. I will try your function, but it will be a while can you tell me now that does your function work like mine?

  1. $typeposition[found][0][1] = "0";
  2. $typeposition[found][0][2] = "1";
  3.  
  4. #ALSO TRY THIS FUNCTION...
  5. /*** Parse n-dimension array and only keep elements with specified value* @param array $array array to be parsed* @param mixed $keep value to keep* @return array*/
  6.  
  7.  
  8. function myFilter(&$array,$keep,$index){
  9. foreach($index as $positions){
  10. $keyedindex[]="[$positions]";
  11. }
  12. $indeximploded = implode("", $keyedindex);
  13.  
  14.  
  15. $result = array();
  16. foreach($array as $key => $val){
  17. if(is_array($val)){
  18. $temp = array();
  19. $temp = myFilter($val, $keep, $index);
  20. if(count($temp)){
  21. $result[$key] = $temp;
  22. unset($temp);
  23. }
  24. }else{
  25. if($val == $keep){
  26. $result[$key] = $val;
  27. }
  28. }
  29. }
  30.  
  31. $function = "
  32. \$array$indeximploded = \$result$indeximploded;
  33. ";
  34. eval($function);
  35. }
  36.  
  37. myfilter($typearray,$element,$typeposition[found][0]);
Last edited by CMCDragonkai : Feb 18th, 2008 at 12:14 am.
Reply With Quote  
All times are GMT -4. The time now is 6:15 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC