Okay, I have an issue with sort(). I can sort the items in the task list, but when
a task is entered with the first letter lowercase, it won’t sort that one. If anyone can point me in the right direction, I would be very appreciative. Thanks!
[php]<?php
if (isset($_POST[‘tasklist’])) {
$task_list = $_POST[‘tasklist’];
} else {
$task_list = array();
// some hard-coded starting values to make testing easier
$task_list[] = 'Write chapter';
$task_list[] = 'Edit chapter';
$task_list[] = 'Proofread chapter';
}
$errors = array();
switch( $_POST[‘action’] ) {
case ‘Add Task’:
$new_task = $_POST[‘newtask’];
if (empty($new_task)) {
$errors[] = ‘The new task cannot be empty.’;
} else {
//$task_list[] = $new_task;
array_push($task_list, $new_task);
}
break;
case 'Delete Task':
$task_index = $_POST['taskid'];
unset($task_list[$task_index]);
$task_list = array_values($task_list);
break;
case 'Modify Task':
$task_index = $_POST['taskid'];
$task_to_modify = $task_list[$task_index];
break;
case 'Save Changes':
$task_index = $_POST['modifiedtaskid'];
$task_m = $_POST['modifiedtask'];
$task_list[$task_index] = $task_m;
break;
case 'Cancel Changes':
$task_to_modify = '';
break;
case 'Promote Task':
$task_index = $_POST['taskid'];
if ($task_index != 0){
$new_index = $task_index - 1;
$temp = $task_list[$new_index];
$task_list[$new_index] = $task_list[$task_index];
$task_list[$task_index] = $temp;
} else{
$e_message = 'Task is already in the first position.';
array_push($errors, $e_message);
} break;
case 'Sort Tasks':
sort($task_list);
break;
}
include(‘task_list.php’);
?>[/php]