I'm been trying to mess with this code for about 10 hours, to make it work for me, I am just not skilled enough ti mind the (most likely) miniscule error, that exists which inhibits the programs functionality. If you can help me I appreciate it, in the meantime I will continue to try to figure this thing out.
Thanks!
This is script.php:
Code: Select all
<?php
$part = substr($_GET['part'], 0, 1);
if (empty($part)) $part = "empty";
$fname = "words.txt";
$handle = fopen($fname, "r");
$string = fread($handle, filesize($fname));
fclose($handle);
function columnSort($unsorted, $column) {
$sorted = $unsorted;
for ($i=0; $i < sizeof($sorted)-1; $i++) {
for ($j=0; $j<sizeof($sorted)-1-$i; $j++)
if ($sorted[$j][$column] > $sorted[$j+1][$column]) {
$tmp = $sorted[$j];
$sorted[$j] = $sorted[$j+1];
$sorted[$j+1] = $tmp;
}
}
return $sorted;
}
function printarray($entryarray,$part){
$found = false;
for ($i=0;$i<count($entryarray);$i++){
if (($part != "empty" && substr($entryarray[$i]['word'], 0, 1) == $part) || $part == "empty"){
if (substr($entryarray[$i]['word'], 0, 1) != $char) {
echo "<h2>- ".substr($entryarray[$i]['word'], 0, 1)." -</h2>";
$char = substr($entryarray[$i]['word'], 0, 1);
}
echo "".$entryarray[$i]['word']." ".$entryarray[$i]['definition'] . $entryarray[$i]['author']." . <br /> . \n";
$found = true;
}
}
if (!$found) echo "Sorry - no entries found!";
}
$entryarray_old = explode("<br />",$string);
$entryarray = array();
for ($i=0;$i<count($entryarray_old);$i++){
$dataarray = explode("<br />","<br />", $entryarray_old[$i]);
$entryarray[$i]['author'] = $dataarray[0];
$entryarray[$i]['word'] = $dataarray[1];
$entryarray[$i]['definition'] = $dataarray[2];
}
$entryarray = columnSort($entryarray, 'word');
printarray($entryarray,$part);
?>Code: Select all
Pulchritude = Great beauty
Contributed by: Chris
Shibby = sweet
Contributed by: jarred
freaktard = A combination of freak and retarded, usually used as someone who is stupid
contributed by: Malina