Page 2 of 2

Re: Escape characters in php

Posted: Wed Jul 29, 2009 9:27 am
by kinabaloo
The calling function is:

Code: Select all

 
    function getContent( $editor )
    {
        $this->_loadEditor();
 
        $args['name'] = $editor;
        $args['event'] = 'onGetContent';
 
        $return = '';
        $results[] = $this->_editor->update($args);
        foreach ($results as $result) {
            //if (trim($result)) 
            {
                $return .= $result;
            }
        }
 
        return $return;
    }
 

Re: Escape characters in php

Posted: Wed Jul 29, 2009 9:33 am
by kinabaloo
i checked the php manual and the use of "\n" in str_replace is ok. I use this elsewhere ok.

In this case, inside the function, str_replace works with normal characters but says 'invalid character' if use \n or @ or #

Re: Escape characters in php

Posted: Wed Jul 29, 2009 9:38 am
by kinabaloo
Maybe I need to define $bbb as an array and do this:

Code: Select all

 
$bbb[]=' ';
        foreach ($newaaa as $result) {
            //if (trim($result)) 
            {
                //$bbb .= $result;
                $bbb[???]=$result;
            }
        }
 
        return $bbb; 
 
But not sure what to put in ???

Re: Escape characters in php

Posted: Wed Jul 29, 2009 9:48 am
by kinabaloo
Now i get '; expected' when add these line:

$bbb=array('a');
return $bbb;

Help !

Re: Escape characters in php

Posted: Wed Jul 29, 2009 2:16 pm
by kinabaloo
McInfo wrote:Rapid-fire posting is a good strategy for convincing other forum users to ignore your thread. It creates the illusion that everyone has abandoned you. It also demonstrates that you are more interested in asking questions than listening to the answers or thinking for yourself.

Take some time to think about your problem and form a concise but complete post that addresses all of your problems, then wait for someone to respond. If you think of something to add, edit your last post rather than firing off multiple posts in a row.
You may be right but I've been struggling with this for about 9 or 10 hours; and i know it's a simple thing but i'm just a noobie .


I guess I need to do something like:

Code: Select all

 
$bbb='';
$order = "\n"; 
$replace = '<br />'; 
 
        foreach ($newaaa as $result) {
            //if (trim($result)) 
            {
                $newaaa[] = str_replace($order, $replace, $result); 
                $bbb[ .... ]=$result;
            }
        }
 
 

Or I just wrap it all in <pre> ... </pre> will be ok but it doesn't work, again because $aaa is not a string i guess but an array of strings.