Jump to content
  • Advertisement
Sign in to follow this  

[web] PHP & Carridge Returns

This topic is 4512 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Heya Im discovering the joys of PHP and MySQL, and thought as a little project I'd create my own blogging software. Ive got a little page which writes the text to a database, and my website retrieves it without any difficulty. The problem is however is that as the text being entered is just straight from the html text box, all of the text is technically just on one line, so any carridge returns that I have entered with inputting the text now have no function. How would I go about replacing these carridge returns with the < br> tag?

Share this post

Link to post
Share on other sites
Find out how they were added while you inputed...they could have been by "\n" (newline) or by "\r\n" (carrige return new line)...

Then search for whatever it is and replace it with <br/>


Share this post

Link to post
Share on other sites
Guest Anonymous Poster
ah ha!

That works perfectly, thank you :)

Rating points coming your way.

Share this post

Link to post
Share on other sites
The most important thing to know about PHP is if there is something you want to do, they probably already have a function to do it.

The proof!

Number of PHP main functions: 3079 [1]
Number of Perl main functions: 206 [2]

Median PHP function name length: 13
Mean PHP function name length: 13.67
Median Perl function name length: 6
Mean Perl function name length: 6.22
* Escaping:

* PHP: (14)
dbx_escape_string, escapeshellarg, escapeshellcmd, pg_escape_bytea,
pg_escape_string, pg_unescape_bytea, addslashes, addcslashes, preg_quote,
quotemeta, mysql_escape_string, mysql_real_escape_string,
mysqli_real_escape_string, sqlite_escape_string

* Perl: (2) [1]
quotemeta, $dbh->quote

* Sorting:

* PHP: (16)
sort, arsort, asort, krsort, ksort, natsort, natcasesort, rsort, usort,
array_multisort, uasort, uksort, dbx_sort, imap_sort, ldap_sort, yaz_sort

* Perl: (1)

* Walking a list

* PHP: (10)
array_filter, preg_grep, array_search, array_unique, in_array, array_map,
array_walk, array_count_values, array_change_key_case, array_sum

* Perl: (2)
map, grep

* Splitting:

* PHP: (8)
split, explode, strtok, spliti, chunk_split, mb_split, preg_split,

* Perl: (1)

* Matching:

* Strings:

* PHP: (11)
strstr, strchr, stristr, strpos, strrchr, stripos, mb_strpos,
mb_strrpos, strrpos, strripos, substr

* Perl: (3)
index, rindex, substr

* Regular expressions:

* PHP: (6)
ereg, eregi, mb_ereg, mb_eregi, preg_match, preg_match_all

* Perl: (1)

* Substituting a matched part:

* PHP: (12)
ereg_replace, eregi_replace, mb_ereg_replace, mb_eregi_replace,
preg_replace, str_ireplace, str_replace, ltrim, rtrim, trim, nl2br

* Perl: (1)

* Connecting to an SQL database:

* PHP: (17)
dbx_connect, fbsql_connect, ibase_connect, msql_connect, msql_pconnect,
mssql_connect, mysql_connect, odbc_connect, pg_connect, pg_pconnect,
sesam_connect, ifx_pconnect, ifx_connect, sqlite_open, sqlite_popen,
mysqli_connect, mysqli_pconnect

* Perl: (2)
DBI->connect, DBI->connect_cached

* Opening:

* PHP: (5)
dio_open, fopen, proc_open, popen, gzopen[2]

* Perl: (2)
open, sysopen

* Reading/receiving:

* PHP: (12)
dio_read, fread, gzread[2], socket_read, socket_recv, socket_recvfrom,
socket_recvmsg, readline, fgetc, fgets, stream_get_line, file

* Perl: (5)
read, readline, sysread, recv, getc

* Printing/writing:

* PHP: (14)
print, echo, printf, fprintf, vprintf, dio_write, fwrite, fputs,
gzwrite[2], socket_send, socket_sendmsg, socket_sendto, socket_write,

* Perl: (5)
print, printf, syswrite, send, write

* Closing:

* PHP: (7)
closelog, dio_close, fclose, gzclose[2], pclose, socket_close,

* Perl: (1)

* Miscellaneous:

* PHP:
array_combine, array_fill, array_merge, list, range, count,
create_function, strtr, pow, putenv, getenv, getmygid, getmypid, getmyuid

* Perl:
syntax or magic variables

Not saying it isn't a great language to work with. Their documentation is excellent on php.net, especially their function index and search. The community comments attached to functions often get around common problems faced when using them. I just with that they would have formed some sort of standard for naming functions or better yet, included namespace support and they could get the bulk of that crap out of the core language.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!