How can data be retrieved from a database and displayed without the "www." prefix in PHP?

When retrieving data from a database in PHP and displaying it on a webpage, the "www." prefix may be included in the URL stored in the database. To remove this prefix before displaying the URL, you can use PHP string functions such as strstr() or str_replace() to manipulate the string and remove the "www." prefix.

// Retrieve URL from database
$url = $row['url'];

// Remove "www." prefix from URL
$url = str_replace('www.', '', $url);

// Display the URL without the "www." prefix
echo $url;