Categories
- Ajax (1)
- Bisdak Blogger (1)
- chicks (1)
- Coffee and Paste (1)
- css (5)
- Excel (1)
- General Info (5)
- HTML (1)
- javascript (8)
- more (8)
- MySQL (1)
- pdf (1)
- Photoshop (1)
- PHP (26)
- SEO (1)
- sports (2)
Blog Archive
-
▼
2009
(38)
-
►
March
(13)
- strlen vs isset in PHP
- 40 Tips for optimizing your php code
- $HTTP_SERVER_VARS
- Cross browser compatibility test site
- Detecting Mobile Browsers in PHP
- Passing JavaScript variables to PHP
- single-quote( ' ) vs double-quote ( " ) in PHP
- PHP Arrays
- Advantages of Using Functions
- Differences between constants and variables
- $_GET vs $_POST in PHP Forms
- require() vs include() in PHP
- What does !important mean in CSS?
-
►
February
(12)
- Javascript onclick return false does not work in I...
- Coffeeandpase Blogger: A Heavy Downloader
- Where is php.ini?
- Make a face
- Turn your photo into a cartoon
- Retrieving Japanese Text from MySQL using PHP
- CSS Play: Experiments with CSS
- New Online MD5 Hash Cracker!
- PNG Alpha Transparency Fix in IE
- Blogger.com as a website instead of a blog?
- Email address validation using Javascript
- PHPMailer: SMTP Authentication
-
►
March
(13)
-
►
2008
(14)
-
►
December
(8)
- Simple php pagination
- Create Image Thumbnails Using PHP and GD
- How to create a dynamic bar graph using PHP and GD...
- How to create a dynamic line graph using PHP and G...
- Simple PHP Image Watermark
- Manny Pacquiao vs Oscar De la Hoya (The Dream Matc...
- Live free streaming!!! Pacquiao vs. De La Hoya
- Javascript equivalent for PHP Functions
-
►
December
(8)
Blog Roll
- Monkeetech
- Atenean101
- Batangsaag.blogspot.com
- Batangyagit.com
- Bethelo
- beyond-the-norms.org
- Brightartclass.blogspot.com
- Bugits
- Cebu Directories
- Cebudaily.com
- CebuCityLife.com
- CebuElection
- Cebuheritage.com
- Cebuimage.blogspot.com
- Cebupacificairlines.ph
- Codes Depot
- Dahonglaya.com
- Empressofdrac
- Errol Duazo
- EUTS
- Iamdownloader.com
- Ibeejing
- Icymartagimacruz
- Ie-student
- In-indie.org
- Jerry Gervacio
- Lagahit.com
- Marian Calago
- Marroxas2010
- Mcbilly.com
- miscelstuffs.blogspot.com
- Miongandmarquee
- Nurseter
- Pinoyworld.org
- Punkies07
- QueerChef
- rentale
- Sinjin.ph
- softwareportables
- Sunchoke.net
- VeganPrince
- Vera
- Veryducky
- Yugatech
PHP_EOL : PHP End Of Line
PHP_EOL is apparently used to find the newline character in a cross-platform-compatible way, so it handles DOS/Mac/Unix issues.
Most of the PHP I write is for generating HTML, and I use <br /> instead of actual newlines, so haven't used (I don't even know) this constant before. Just until I need to explode a block of string to be separated by the end of the line. It's something like the file() function can do but I only want to parse a string, I dont want to put it into another file.
There were no \r\n added to the end of each line on the string that would be used as identifier for the explode. I know I can just add it myself but the string is dynamic, it's from a user input.
So I googled for some workaround but no luck, I don't know, may be its my search keywords. I wander at php.net and landed on this page.
There I found about PHP_EOL, so I tried to use it and voila, works like magic.
Sample code:
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31<?php
$str='IT sa CITE Batch 6
Glendon Alimin
John Reeve Belarmino
Carl Anthony Campos
Alex Culango
Joenar Dalumpines
Ryan Dupay
Victoriano Eco II
Ronald Enclonar
Johnric Godinez
Jerry Laborte
Jim Carl Luzano
Licerio Maeza
Joseph Marvin Magdadaro
Ramil James Mangapis
Ryan Christoper Maramot
Mitchell Masinas
Paulino Muñez
Francis Ray Ranile
Reynold Salceda
Jeb Agustin Saldariega
Rholyn Sampan
Kenneth Sotto
Michael Sumayang
Chrissan Versoza
Roel Villarba ';
print_r($arr);
?>
the above code returns:
Array
(
[0] => IT sa CITE Batch 6
[1] => Glendon Alimin
[2] => John Reeve Belarmino
[3] => Carl Anthony Campos
[4] => Alex Culango
[5] => Joenar Dalumpines
[6] => Ryan Dupay
[7] => Victoriano Eco II
[8] => Ronald Enclonar
[9] => Johnric Godinez
[10] => Jerry Laborte
[11] => Jim Carl Luzano
[12] => Licerio Maeza
[13] => Joseph Marvin Magdadaro
[14] => Ramil James Mangapis
[15] => Ryan Christoper Maramot
[16] => Mitchell Masinas
[17] => Paulino Muñez
[18] => Francis Ray Ranile
[19] => Reynold Salceda
[20] => Jeb Agustin Saldariega
[21] => Rholyn Sampan
[22] => Kenneth Sotto
[23] => Michael Sumayang
[24] => Chrissan Versoza
[25] => Roel Villarba
)
This entry was posted on Tuesday, August 11, 2009
and is filed under
PHP
.
You can follow any responses to this entry through
the RSS 2.0 feed.
You can leave a response,
or trackback from your own site.



3 comments:
ay,,, wala akong alam sa php.. pero magtry ako nyan...
sa hmtl may alam ako kunti lng.heheh
thnx.. i already added both your links in my page.
thanks
Post a Comment