Hello, I Need Some Help, I Have This Text I Need to Show It As Please Suggest preg replace pattern, or something else to show blockqoute as bold tag
If you know you will only have two quotes then you could do this $str= 'Hello "some text" Howdy'; $arr = explode('"', $str, 3); if (count($arr) > 0) { $str = $arr[0] . "<b>" . $arr[1] . "</b>" . $arr[2]; } PHP: You could loop through the array if you had more quoted text and not limit the explode I guess. Hope that helps.
This'll work: $string = str_replace('"','',preg_replace('/"[^"]*"/', '<b>$0</b>', $string)); Code (markup):
$str = 'This Is Bla "Blah", "Blah"'; $pattern = '/["][^"]{2,}["]/'; echo $replace = preg_replace($pattern, '<b>'.Replaced Text.'<b>', $str); PHP: It Returns Error, I Have to Show Replaced Text
Wait... right now you're asking about something else entirely - that's not the same question as the one above?
Ah, sorry. Yes, but maybe not if you're trying to replace something with something else? Or was that just another try?