How can PHP be used to sort data from a table based on multiple columns, such as prices?

To sort data from a table based on multiple columns, such as prices, you can use the `array_multisort()` function in PHP. This function allows you to sort multiple arrays or multidimensional arrays based on one or more columns. You can specify the columns to sort by and the sorting order (ascending or descending) for each column.

// Sample data from a table
$data = array(
    array('id' => 1, 'name' => 'Product A', 'price' => 50),
    array('id' => 2, 'name' => 'Product B', 'price' => 30),
    array('id' => 3, 'name' => 'Product C', 'price' => 40),
);

// Sort the data by price in ascending order
$prices = array_column($data, 'price');
array_multisort($prices, SORT_ASC, $data);

// Display the sorted data
foreach ($data as $product) {
    echo $product['name'] . ' - $' . $product['price'] . '<br>';
}