<?php
function walkit($item2, $key)
{
   echo "<tr><td>$key<td> $item2\n";
}

#read in file 
$yourfile="../../data/requests.xyz";
$linecount=0;
$myString = "";
$skills = array();
$file = fopen($yourfile,"r") or die ("No such file $yourfile.\n");
while(!feof($file)){
    $line = fgets($file,256);
    trim($line);
    $linecount++;
    ereg('^([-A-Za-z]{1,})[[:space:]](.*)$',$line,$myline_array);
    $skills[$myline_array[1]] = $myline_array[2];
    print "<br>  $myline_array[1] = $myline_array[2]";
    $myString .= "<br> $line";
}
fclose($file);
#print out each person
print "<hr>";
//Walk the file
print "<table border=1><th>Key<th>Item\n";
array_walk($skills,"walkit");
print "\n</table>";


#print out the file line by line
print $myString;


#the proper way
$people = file($yourfile);
foreach ($people as $person){
    $fields = split("[[:space:]]+",$person);
    $key = $fields[0];
    array_shift($fields);
    $value = join(" ",$fields);
    $ptab[$key] = $value;
}
ksort($ptab);

foreach (array_keys($ptab) as $n){
    print "<br>$n $ptab[$n]";
}

?>

-- PeterJones - 09 Nov 2006

Edit | Attach | Watch | Print version | History: r1 | Backlinks | Raw View | WYSIWYG | More topic actions
Topic revision: r1 - 2006-11-09 - PeterJones
 
    • Cern Search Icon Cern Search
    • TWiki Search Icon TWiki Search
    • Google Search Icon Google Search

    Main All webs login

This site is powered by the TWiki collaboration platform Powered by PerlCopyright & 2008-2019 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback