using an escape functionality within the split function

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
twindu
Forum Newbie
Posts: 5
Joined: Mon Aug 25, 2003 3:32 pm

using an escape functionality within the split function

Post by twindu »

I have the following comma delimited string which I am trying to use the split function on

Address,Contact Info,<serial number>,"GPA",12345678890123456

for some reason.... <serial number> is being replaced with a blank space....
can someone please explain why this is happening and give me a possible solution
User avatar
JAM
DevNet Resident
Posts: 2101
Joined: Fri Aug 08, 2003 6:53 pm
Location: Sweden
Contact:

Post by JAM »

Code: Select all

<pre>
<?php
$string = 'Address,Contact Info,<serial number>,"GPA",12345678890123456';
$foo = split(',',$string);
print_r($foo);
?>
The above works fine. But, using my debugging method print_r, you will still get the blank line. Or so it seems.
If you run this on a clean page, and then viw the source, you'll see the <serial number> as it is.

The browser just tries to use it as a html-tag...
Either remove the <>'s or convert them into ascii/htmlentities etc.
Post Reply