0

Hello, there is a simple code I'm writing but can't find exactly where I'm going wrong.

$data = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis eget tellus cursus, ultrices justo at, ultricies libero. Vivamus consequat ante vel nunc dapibus, non tempus elit vehicula. Nulla facilisi. Proin leo urna, congue eu justo eget, viverra mattis lacus.
#otwquote";
preg_match_all('/\s#otw[0-9a-z]+\b/i', $data, $matches);
$matchtag = str_replace("#otw", "", strtolower($matches[0][0]));
echo $matchtag;
$formats = array("status", "aside", "link", "gallery", "image", "audio", "video", "quote", "chat", "standard");
$backhash ="standard";

// here $matchtag = "quote"

if ( in_array ( $matchtag , $formats ) ) {  
echo $matchtag;
} else {
echo $backhash;
}

Now when I'm using

if ( in_array ( "quote" , $formats ) )

It's working fine. But with variable $matchtag it's returning false.
Please help.
Thanks

2
Contributors
3
Replies
15
Views
4 Years
Discussion Span
Last Post by urbangeek
0

Looking at your codes, the variable matchtag should return "quote" and backhash returns 'standard'.

0

Yes...so if "quote" is found in $formats it will show "quote", else "standard"...but when I'm doing that using $matchtag its not working.

N.B: I've found if I put $matchtag = "quote" on line no 9, it works fine. So is there any problem with the formatting of $matchtag variable?

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.