Welcome Guest, Not a member yet? Register   Sign In
Help me..
#5

(01-05-2016, 06:50 AM)PaulD Wrote: Or loop through your data in php. Use a counter to add the 1,2,3 to the end of the default type, name, description variables, and create your array from the data you have.
PHP Code:
<?php
     $source_data 
= array (
 
         "type1" => "controller",
 
         "name1" => "eg1",
 
         "description1" => "desc1",
 
         "type2" => "function",
 
         "name2" => "c2",
 
         "description2" => "desc 2",
 
         "type3" => "controller",
 
         "name3" => "c3",
 
         "description3" => "c3 descr",
 
    );

 
    $count 1;
 
    $checking TRUE;
 
    $output_data = array();
 
    
     
while ($checking)
 
        
          $temp_data 
= array();
 
         
          if 
(isset($source_data['type'.$count]))
 
         {
 
              $temp_data['type'] = $source_data['type'.$count];     
          
         
          if 
(isset($source_data['name'.$count]))
 
         {
 
              $temp_data['name'] = $source_data['name'.$count];
 
                  
          if 
(isset($source_data['description'.$count]))
 
         {
 
              $temp_data['description'] = $source_data['description'.$count];
 
         }
 
         
          if 
(count($temp_data) > 0)
 
         {
 
              $output_data[] = $temp_data;
 
         }
 
         else
          
{
 
              $checking FALSE;
 
         }
 
         
          
++$count;
 
         
     
}
 
    
     
echo print_r($output_data);
 
    
?>

Sorry but this is a horrible idea.
Reply


Messages In This Thread
Help me.. - by ngangchill - 01-04-2016, 01:51 PM
RE: Help me.. - by Diederik - 01-04-2016, 03:52 PM
RE: Help me.. - by Aendawan - 01-04-2016, 04:01 PM
RE: Help me.. - by PaulD - 01-05-2016, 06:50 AM
RE: Help me.. - by mr_pablo - 01-05-2016, 08:30 AM
RE: Help me.. - by ngangchill - 01-05-2016, 08:49 AM
RE: Help me.. - by PaulD - 01-05-2016, 08:57 AM
RE: Help me.. - by PaulD - 01-05-2016, 08:35 AM
RE: Help me.. - by mr_pablo - 01-05-2016, 08:43 AM
RE: Help me.. - by PaulD - 01-05-2016, 08:55 AM
RE: Help me.. - by includebeer - 01-09-2016, 09:41 AM



Theme © iAndrew 2016 - Forum software by © MyBB