Are there specific functions in PHP that can be used to manipulate and format data extracted from external sources?
When extracting data from external sources in PHP, you may need to manipulate and format the data before displaying it on your website. PHP provides various built-in functions that can be used for this purpose, such as `json_decode()` for decoding JSON data, `strip_tags()` for removing HTML tags, `trim()` for removing whitespace, `htmlspecialchars()` for converting special characters to HTML entities, and `date()` for formatting dates.
// Example of manipulating and formatting data extracted from an external source
$rawData = '{"name": "<b>John Doe</b>", "age": 25, "dob": "1996-05-15"}';
// Decode JSON data
$data = json_decode($rawData, true);
// Remove HTML tags from name
$name = strip_tags($data['name']);
// Format date of birth
$dob = date('F j, Y', strtotime($data['dob']));
// Display formatted data
echo "Name: " . htmlspecialchars($name) . "<br>";
echo "Age: " . $data['age'] . "<br>";
echo "Date of Birth: " . $dob;