diff --git a/week-1/test_app/includes/functions.php~ b/week-1/test_app/includes/functions.php~ deleted file mode 100644 index 7d32205eafd81be12d0eb80e2497137a680b8eb6..0000000000000000000000000000000000000000 --- a/week-1/test_app/includes/functions.php~ +++ /dev/null @@ -1,77 +0,0 @@ -<?php -function formatMoney($number) { - $formatted = number_format($number, 2); -return $formatted; -} - -function formatAuthors($author_array) { - if ( count($author_array) == 1 ) { - return $author_array[0]; - } elseif ( count($author_array) == 2 ) { - return $author_array[0] . " and " . $author_array[1]; - } else { - $author_string = ""; - for ($i=0;$i<count($author_array);$i++) { - if ($i==count($author_array)-2) { - $author_string .= " and "; - } elseif ( $i==count($author_array)-1) { - $author_string .= $author_array[$i]; - } else { - $author_string .= $author_array[$i].", "; - } - } - return $author_string; - } -} - -// Function to return formatted string of book fields -function formatBook( $title, $isbn, $price, $date, $authors ) { - - $book_string ='<tr>'; - - if (isset($title)) { - $book_string .= '<td>'.htmlentities($title).'</td>'; - } else { - $book_string .= '<td> </td>'; - } - - if (isset($isbn)) { - $book_string .= '<td>'.htmlentities($isbn).'</td>'; - } else { - $book_string .= '<td> </td>'; - } - - if (isset($price)) { - $book_string .= "<td>£".htmlentities($price)."</td>"; - } else { - $book_string .= '<td> </td>'; - } - - if (isset($date)) { - $date_string = formatDate($date); - $book_string .= "<td>".htmlentities($date_string)."</td>"; - } else { - $book_string .= '<td> </td>'; - } - - if (isset($authors)) { - $author_string = formatAuthors( $authors ); - $book_string .= "<td>".$author_string."</td>"; - } else { - $book_string .= '<td> </td>'; - } - - $book_string .='</tr>'; - return $book_string; -} - -// Function to standardise date formats -function formatDate($date) { - $timestamp = strtotime($date); - $date_string = date('dS F Y', $timestamp); - return $date_string; -} - - -?> -