How can variable values be stored or displayed from an array in PHP?
To store or display variable values from an array in PHP, you can use array indexing to access specific elements within the array. You can store these values in separate variables for easier manipulation or display them directly using echo or print statements.
// Define an array with some values
$numbers = array(10, 20, 30, 40, 50);
// Store specific values from the array in separate variables
$num1 = $numbers[0];
$num2 = $numbers[1];
// Display the values stored in the variables
echo "Number 1: " . $num1 . "<br>";
echo "Number 2: " . $num2 . "<br>";
// Alternatively, you can directly display values from the array
echo "Number 3: " . $numbers[2] . "<br>";