Escape characters in php

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

kinabaloo
Forum Commoner
Posts: 35
Joined: Tue Jul 28, 2009 11:20 pm

Re: Escape characters in php

Post 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;
    }
 
kinabaloo
Forum Commoner
Posts: 35
Joined: Tue Jul 28, 2009 11:20 pm

Re: Escape characters in php

Post 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 #
kinabaloo
Forum Commoner
Posts: 35
Joined: Tue Jul 28, 2009 11:20 pm

Re: Escape characters in php

Post 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 ???
kinabaloo
Forum Commoner
Posts: 35
Joined: Tue Jul 28, 2009 11:20 pm

Re: Escape characters in php

Post by kinabaloo »

Now i get '; expected' when add these line:

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

Help !
kinabaloo
Forum Commoner
Posts: 35
Joined: Tue Jul 28, 2009 11:20 pm

Re: Escape characters in php

Post 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.
Post Reply