How to declare an array with one item calling a function?
<p>I'm working on a project that will produce lots of tables from data stored in a text files.</p>

<p>anyway I want to have my code look something like this ..</p>

<pre><code>   function Phone($arg){
   ....
   return $phone_nr
   }

   function Adress($arg){
   ....
   return $adress_nr
   }

   function Arr_push($args) {
        for ($i = 1; $i &lt; func_num_args(); $i++) {
            $keys[$i - 1] = func_get_arg($i);
        }
        foreach ($keys as $key) {
            $arr_return[] = $key;
        }
        return $arr_return;
    }

    $Table1[] = Arr_push($DB,'Name:', 'John', 'Gender:', 'male');
    $Table1[] = Arr_push($DB,'phone:', Phone('John'), 'Address', Adress('John'));

    $table = new TableClass();
    $table-&gt;show($Table1);

    ($DB is the database a 2d array with keys and values)
</code></pre>

<p>Could this be done ? Or do I have to write a some kind of parser for this</p>

<pre><code>"Parser method"

 $Table1[] = Arr_push('phone:', '^phone,John', 'Address', ^adress,John');

 in Arr_push function check if the string start with a '^'. In that case explode
 it on the delimiter ',' and have switch loop for the different cases. 
</code></pre>

<p>I have been searching for this several days no so I have to raise the question.</p>

<p>Extends the information ...</p>

<p>the file look like this ...</p>

<p>1 2 
PRD~1 3 
ISO 8859-1~1 4 0 ~2 1 
Rundvirke Skog~2 2 
VIRK1209.APT~3 1 
311214~3 2 
000000~3 3 1 ~803 4 
311214~3 5 
Valmet~3 6 
911.3~3 7 
........it goes on and on</p>

<p>Have managed with awful regex : </p>

<pre><code>%((\d{1,}\s?)+(?=~))|(((\d{1,}\s\d{1,})\s?\r?\n)(^(\w|\s|[å-ö]|[Å-Ö]|,|\.|
    \?|-|\?|@|\*|/)+))%mx 
</code></pre>

<p>read it into a 2d array like this  ...</p>

<pre><code>[Var_id] [Type]  [Data]
 1        4       0 
 1        3       ISO 8859-1
 1        2       PRD
 2        2       VIRK1209.APT
 2        1       Rundvirke Skog
 3        6       911.3
 3        7       Valmet 
 3        8       360.1/360.2
 3        5       Valmet
 3        3       1
 3        2       000000
  .....
</code></pre>

<p>The output I want is table with some data for exampel</p>

<pre><code>| Machine   | Valmet  | Type  | 911.3
| ......    | ......
</code></pre>

<p>The data (Valmet and 911.3) is called by its [Var_id] and  [Type]</p>

<p>So when doing thoose tables i would be nice to have a "clean" code</p>

<pre><code>   $array[] = arr_push($DB, 'Produktion:', '', 'Apteringsinstruktion:', '');
    $array[] = arr_push($DB, 'FilNamn:', '^get, 1, 2', 'Filnamn:', '^get, 2, 2');
    $array[] = arr_push($DB, 'Nollställ datum:', '^get, 11, 4', 'Indetitetsuppgifter', '^get, 2, 1');
    $array[] = arr_push($DB, 'Lagrind datum:', '^get, 12, 4', 'Skapat datum:', '^get, 13, 4');
    display_table($array);

    How the input looks like now with the "parser" method.
</code></pre>

<p>So is there way to replace this '^get,var_id,type' parser with a function call instead?</p>

<p>More info about the StandforD standard could be found on : <a href="http://www.skogforsk.se/en/About-skogforsk/Collaboration-groups/StanForD/" rel="nofollow">http://www.skogforsk.se/en/About-skogforsk/Collaboration-groups/StanForD/</a></p>

<p>More on the file wich explain [var_id] [type]  : <a href="http://www.skogforsk.se/PageFiles/60712/AllVarNo_ENG_120418.pdf" rel="nofollow">http://www.skogforsk.se/PageFiles/60712/AllVarNo_ENG_120418.pdf</a>.</p>

<p>Background:
Harvester is producing prd files wich include all the timber and volyme and time etc.. There are no free viewers for that on the market (what I know about). So I'm doing a prd viewer i PHP.</p>

<p>I don't know where to host this so I don't want a sql server as backend.</p>
