1) { if(trim($_POST['firstName']) == '' || trim($_POST['lastName']) == '' || trim($_POST['comment']) == '' || trim($_POST['priority']) == '') { $message = '
All inputs are required!
'; } else { $message = '
Thank you ' . trim(ucwords(strtolower($_POST['title']))) . " " . $_POST['firstName'] . ' ' . $_POST['lastName'] . '! . ' . date('F dS, Y', time()).'.
'; } move_uploaded_file($_FILES['file']['tmp_name'], 'uploads/' . $_FILES['file']['name']); $fp = fopen("posts.txt", "a+"); fwrite($fp, trim(ucwords(strtolower($_POST['firstName']))) . ',' . trim(ucwords(strtolower($_POST['lastName']))) . ',' . trim(ucwords(strtolower($_POST['title']))) . ',' . trim($_POST['comment']) . ',' . trim($_POST['priority']) . ',' . time() . ',' . $_FILES['file']['name'] . PHP_EOL); fclose($fp); } // if(count($_POST) > 1) // var_dump($_POST); // echo "
"; // var_dump($_FILES); ?> COMP 3015

1) // { // second one $posted_arrays = array(); $lines = file("posts.txt"); /* function cmp($a, $b) { if ($a == $b) { return 0; } return ($a < $b) ? -1 : 1; } // $a = array(3, 2, 5, 6, 1); uasort($lines, "cmp"); foreach ($lines as $key => $value) { echo "$key: $value\n"; } */ rsort($lines); // shuffle($lines); // ksort($lines, $each_posted_array[4]); // array_multisort($lines, $each_posted_array[4]); foreach($lines as $key => $line) { $words = explode(',', $line); // $words = preg_split("/,/", $line); $each_posted_array = array(); foreach($words as $key => $word) { $each_posted_array[$key] = $word; // echo '$each_posted_array['.$key.'] ='.$word; } $posted_arrays[$key] = $line; ?>
First Post!

Posted on

$line) // } // if(count($_POST) > 1) // second one ?>
First Post!

Posted on