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

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

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?

Ok..I had to put $matchtag = trim($matchtag);

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.