Jump to content

Problem with split


Xeon-YK

Recommended Posts

i have a problem with split.
i want to ask how if i want split the string with enter character

example :

i have string :

rudy 10 male
eric 12 male
john 13 male

when i split with enter character i will become three part
1. rudy 10 male
2. eric 12 male
3. john 13 male

i have try with this $temp_str = split('\n', $str);

but i didn't work, the result is split with n character.

how to solve this problem, thank...
Link to comment
https://forums.phpfreaks.com/topic/9036-problem-with-split/
Share on other sites

The problem you're seeing is that you used single quotes around the newline character instead of double quotes. Any string inside single quotes is treated literaly -- no expansions.

Try this:
[code]<?php $temp_str = split("\n", $str); ?>[/code]

For [b]askjames01[/b]: you gave the OP a solution to a problem he didn't ask about and my not have.

Ken
Link to comment
https://forums.phpfreaks.com/topic/9036-problem-with-split/#findComment-33256
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.