php-general Digest 2 Apr 2010 23:05:23 -0000 Issue 6672
Topics (messages 303749 through 303755):
str_replace help
303749 by: David Stoltz
303750 by: Ashley Sheridan
303751 by: Midhun Girish
303752 by: Nilesh Govindarajan
SimpleXMLElement and gb2312 or big5
303753 by: Peter Pei
SimpleXMLElement occasionally fails to parse gb2312 or big5 feeds
303754 by: Peter Pei
convert a string into an array
303755 by: Andre Polykanine
Administrivia:
To subscribe to the digest, e-mail:
php-general-digest-subscr...@lists.php.net
To unsubscribe from the digest, e-mail:
php-general-digest-unsubscr...@lists.php.net
To post to the list, e-mail:
php-gene...@lists.php.net
----------------------------------------------------------------------
--- Begin Message ---
Hi folks,
In ASP, I would commonly replace string line feeds for HTML output like
this:
Var = replace(value,vbcrlf,"<br>")
In PHP, the following doesn't seem to work:
$var = str_replace(chr(13),"\n",$value)
Neither does:
$var = str_replace(chr(10),"\n",$value)
What am I doing wrong?
Thanks!
--- End Message ---
--- Begin Message ---
On Fri, 2010-04-02 at 09:28 -0400, David Stoltz wrote:
> Hi folks,
>
> In ASP, I would commonly replace string line feeds for HTML output like
> this:
>
> Var = replace(value,vbcrlf,"<br>")
>
> In PHP, the following doesn't seem to work:
> $var = str_replace(chr(13),"\n",$value)
>
> Neither does:
> $var = str_replace(chr(10),"\n",$value)
>
> What am I doing wrong?
>
> Thanks!
I see no reason why it shouldn't work other than maybe the string
doesn't contain what you think it does.
Thanks,
Ash
http://www.ashleysheridan.co.uk
--- End Message ---
--- Begin Message ---
well david actually $var = str_replace(chr(13),"\n",$value) will replace
char(13) with \n... but \n wont come up in html unless u give a <pre> tag..
u need to put
$var = str_replace(chr(13),"<br/>",$value) in order to got the required
output....
Midhun Girish
On Fri, Apr 2, 2010 at 7:03 PM, Ashley Sheridan
<a...@ashleysheridan.co.uk>wrote:
> On Fri, 2010-04-02 at 09:28 -0400, David Stoltz wrote:
>
> > Hi folks,
> >
> > In ASP, I would commonly replace string line feeds for HTML output like
> > this:
> >
> > Var = replace(value,vbcrlf,"<br>")
> >
> > In PHP, the following doesn't seem to work:
> > $var = str_replace(chr(13),"\n",$value)
> >
> > Neither does:
> > $var = str_replace(chr(10),"\n",$value)
> >
> > What am I doing wrong?
> >
> > Thanks!
>
>
> I see no reason why it shouldn't work other than maybe the string
> doesn't contain what you think it does.
>
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>
>
>
--- End Message ---
--- Begin Message ---
On 04/02/10 18:58, David Stoltz wrote:
Hi folks,
In ASP, I would commonly replace string line feeds for HTML output like
this:
Var = replace(value,vbcrlf,"<br>")
In PHP, the following doesn't seem to work:
$var = str_replace(chr(13),"\n",$value)
Neither does:
$var = str_replace(chr(10),"\n",$value)
What am I doing wrong?
Thanks!
Use nl2br.
--
Nilesh Govindarajan
Site & Server Administrator
www.itech7.com
मेरा भारत महान !
मम भारत: महत्तम भवतु !
--- End Message ---
--- Begin Message ---
I use the following code to get rss and parse it, but the code
occasionally have issues with gb2312 or big-5 encoded feeds, and fails to
parse them. However other times may appear just okay. Any thoughts? Maybe
SimpleXMLElement is simply not meant for other language encodings...
$page = file_get_contents($rss);
try {
$feed = new SimpleXMLElement($page);
--- End Message ---
--- Begin Message ---
I use the following code to get rss and parse it, but the code
occasionally have issues with gb2312 or big-5 encoded feeds, and fails to
parse them. However other times may appear just okay. Any thoughts? Maybe
SimpleXMLElement is simply not meant for other language encodings...
$page = file_get_contents($rss);
try {
$feed = new SimpleXMLElement($page);
--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
--- End Message ---
--- Begin Message ---
Hello everyone,
It's quite simple but I'm still stuck.
What I need is the following: I have an array as a parameter of my
custom function. However, I'd like to allow users to enter a string
instead of an array. In this case (if the parameter is a string), it
must be replaced with an array containing only one item - actually,
that string.
What I'm doing gives me (presumably) errors;
function Send ($tonames, $toemails, $subject, $message) {
...
if ((!is_array($tonames)) || (!is_array($toemails))) {
$tonames[]=$tonames;
$toemails[]=$toemails;
}
I can't give the new array a new name since I address it further in a
loop as my function's parameter... hope you understand what I'm
saying)
Thanks!
--
With best regards from Ukraine,
Andre
Http://oire.org/ - The Fantasy blogs of Oire
Skype: Francophile; Wlm&MSN: arthaelon @ yandex.ru; Jabber: arthaelon @
jabber.org
Yahoo! messenger: andre.polykanine; ICQ: 191749952
Twitter: http://twitter.com/m_elensule
--- End Message ---