if a,b,c

Robert9

Well-known member
I can do

if a=
elseif b =
elseif c=

means that a= will break and save running time

What happens when I do

if a= or b= or c=
will php stop working here also if a= is true?
 
Can I short this?

PHP:
        if (
            (preg_match('#\[opener\](.*)\[/opener\]#is', $message, $matches))
            || (preg_match('#\[excerpt\](.*)\[/excerpt\]#is', $message, $matches))
            || (preg_match('#\[snippet\](.*)\[/snippet\]#is', $message, $matches))
        )
 
I can do

if a=
elseif b =
elseif c=

means that a= will break and save running time

What happens when I do

if a= or b= or c=
will php stop working here also if a= is true?
Yes, it will stop evaluating the rest of the if-statement as soon as it has a match.
 
Works with $matches[2], tahnk you.
the next step would be not so easy, i guess:

Any idea how to sub_str my snippet without cutting bbcodes?

b, i, u could maybe be cut and get a new [/end
but we can't cut attach]
 
Can I short this?

PHP:
        if (
            (preg_match('#\[opener\](.*)\[/opener\]#is', $message, $matches))
            || (preg_match('#\[excerpt\](.*)\[/excerpt\]#is', $message, $matches))
            || (preg_match('#\[snippet\](.*)\[/snippet\]#is', $message, $matches))
        )

Take care:

(preg_match('#\[opener\](.*)\[/opener\]#is', $message, $matches));
|| (preg_match('#\[excerpt\](.*)\[/excerpt\]#is', $message, $matches));
|| (preg_match('#\[snippet\](.*)\[/snippet\]#is', $message, $matches));
 
Thank you, code is changed like

Code:
   public function setPreview(&$error = null)
    {
        $message = $this->message;
        $options = \XF::options();

        if (
            preg_match('#\[(opener|excerpt|)\](.*)\[/\1\]#is', $message, $matches)
        )
        {
            $this->message = trim($matches[2]);
        }
        elseif (preg_match('#\[snippet\](.*)\[/snippet\]#is', $message, $matches))
        {
            $this->message = trim(substr($matches[1], 0, $options->xcTopics1SnippetLength)) . " ...";
        }
        else
        {
            if ($options->XCTopics1TopicsUseSnippetAlways)
            {
                $this->message = trim(substr($message, 0, $options->xcTopics1SnippetLength)) . " ...";
            }
        }
    }
 
if ( preg_match('#\[(opener|excerpt|)\](.*)\[/\1\]#is', $message, $matches) ) { .......

I believe it should be:
if (preg_match('#\[(opener|excerpt|)\](.*)\[/\1\]#is', $message, $matches) {
 
Back
Top Bottom