Return the file extension portion of a filename

This was another question in a skills evaluation test Write a regular expression for the following code that will trim off the extension from a filename: $ext = preg_replace(‘/xxxxx/’, ’’, $filename); My solution: $ext = preg_replace(‘/^.*\.([^.]+)$/D’, ‘$1’, $filename); I find regular expressions pretty tricky, so usually end up using an online tool like this: In […]


Complex SQL query using SUM and GROUP BY

Got this question as part of a skills evaluation test. It requires a query to calculate summary-like data from tables in an order system type database. There is an `orders` table that consists of an order_no and customer_id fields. Also, an `order_items` table that consists of order_item_id, order_id, product_id, qty, unit_price and total. unit_price is […]