What is the purpose of using a text file to replace smilies in PHP code?

When using smilies in PHP code, it can be helpful to store them in a text file so that they can be easily updated or modified without needing to change the actual code. This can make managing smilies more efficient and flexible.

$smilies = file('smilies.txt', FILE_IGNORE_NEW_LINES);
$text = "Hello :) This is a test :D";

foreach($smilies as $smiley) {
    $text = str_replace($smiley, '<img src="smiley.png">', $text);
}

echo $text;