473,378 Members | 1,390 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

trim'ing  

<?
echo 'a'.trim(html_entity_decode('&nbsp;a&nbsp;')).'a';
?>

Shouldn't PHP output aaa? Looking at the documentation for trim I see
that it doesn't support chr(0xA0) (eg. html_entity_decode('&nbsp;')),
but it seems to me like it ought to...

Feb 22 '06 #1
3 8885

yawnmoth wrote:
<?
echo 'a'.trim(html_entity_decode('&nbsp;a&nbsp;')).'a';
?>

Shouldn't PHP output aaa? Looking at the documentation for trim I see
that it doesn't support chr(0xA0) (eg. html_entity_decode('&nbsp;')),
but it seems to me like it ought to...


That's what the second parameter to trim() is for. You could do this
instead:

echo 'a'.trim(html_entity_decode('&nbsp;a&nbsp;'), "\xA0").'a';

Feb 22 '06 #2

ZeldorBlat wrote:
yawnmoth wrote:
<?
echo 'a'.trim(html_entity_decode('&nbsp;a&nbsp;')).'a';
?>

Shouldn't PHP output aaa? Looking at the documentation for trim I see
that it doesn't support chr(0xA0) (eg. html_entity_decode('&nbsp;')),
but it seems to me like it ought to...


That's what the second parameter to trim() is for. You could do this
instead:

echo 'a'.trim(html_entity_decode('&nbsp;a&nbsp;'), "\xA0").'a';

If I do that, I'll either have to do two trims or readd all the
parameters back in. I say that because...

<?
echo 'a'.trim(' a ',chr(0xA0)).'a';
?>

....has spaces in it.

Feb 22 '06 #3
yawnmoth wrote:
<?
echo 'a'.trim(html_entity_decode('&nbsp;a&nbsp;')).'a';
?>

Shouldn't PHP output aaa? Looking at the documentation for trim I see
that it doesn't support chr(0xA0) (eg. html_entity_decode('&nbsp;')),
but it seems to me like it ought to...


Hi yawnmoth,

&nbsp; is NOT something that is encoded/decoded.

htmlentities is a function that will make sure ALL possible html-markup
characters will be displayed right in html.
(and decode puts them back)

If you feed &nbsp; to htmlentities you will get only the 'dangerous'
characters encoded, thus the &
so that would result in:
&amp;nbsp;

Bottomline: &nbsp; is just a string to htmlencode and decode. Only the & is
of importance to their functionality.

Regards,
Erwin Moller
Feb 22 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Robert Mark Bram | last post by:
Hi All, I am using the following trim function: function trim (str) { return str.replace(/^\s*/g, '').replace(/\s*$/g, ''); } The problem is that this doesn't trim instances of the...
2
by: John A Grandy | last post by:
anyone know why this is ? Imports System.Data Imports System.Diagnostics Public Class WebForm12
1
by: Calvin KD | last post by:
Hi everyone, Can someone show me how to display an empty string in a boundcolumn of a datagrid when the data source item is NULL. Datagrid by default displays the and that's BAD!!!!! I've tried...
4
by: drew197 | last post by:
I am a newbie. I am editing someone elses code to make it compatible with Firefox and Safari. In IE, when you click on the proper link, a block of text is shown in a nice paragraph form. But, in...
12
by: JA | last post by:
Is there a way to remove all the white space in the fields? I have been using Find-and-replace - looking for 2 or 3 or 4 or 10 spaces and replacing them with none. I don't want to replace single...
0
by: gunimpi | last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431 ******************************************************** VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help wanted...
0
by: chittu07 | last post by:
Hi, I am sending my code ,my query is running right but in the pagging the content(data) of last page are display on first page so when ever next button is clicked no data are displaying ...
4
by: mattehz | last post by:
Hey there, I am trying to upload old source files and came across these errors: Warning: Invalid argument supplied for foreach() in /home/mattehz/public_html/acssr/trunk/inc_html.php on line 59...
5
matheussousuke
by: matheussousuke | last post by:
Hello, I'm using tiny MCE plugin on my oscommerce and it is inserting my website URL when I use insert image function in the emails. The goal is: Make it send the email with the URL...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.