Jump to content

str_replace line breaks?


amplexus

Recommended Posts

so, I'm working to create an easy user interface for a restaurant owner to be able to edit the menu on their site as often as they want, and not have to go through me.  I've set up a .txt file that they can edit - "menu.txt". and set up the code to call the contents of that file to display.  I've then set up css to format the called text.  pretty pretty, and simple.  the real problem occurs because I want to have the menu have proper line breaks; it isn't a straight paragraph.  so, I figured I could have a str_replace function do the work, to include a <br> where I need it.  works great.  except I have no idea how to have PHP read a line break from a .txt file so I have to have a double space (two spaces) stand in for a line break.  works okay, but i would rather not have to confuse my client with a mickey mouse solution.  anyone see a way around this?  here's my code:

 

<?php $menutext = file_get_contents ('menu.txt');

echo $breakup = str_replace("  ", "<br>", "$menutext");

?>

 

help?

Link to comment
https://forums.phpfreaks.com/topic/174359-str_replace-line-breaks/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.