Guest User

Untitled

a guest
May 26th, 2018
424
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. echo preg_replace('#<hr *id="system-readmore" */>.*#is','',$this->row->product_description);
  2.  
  3. // this is your $this->row->product_description value for demonstration purposes:
  4. $html = <<<HTML
  5. Some text yatta yatta
  6. <hr id="system-readmore" />
  7. Some more text blah blah
  8. HTML;
  9.  
  10. list($introtext, $description) = explode('<hr id="system-readmore" />', $html, 2);
  11. var_dump($introtext);
  12. var_dump($description);
  13.  
  14. echo "n---n";
  15.  
  16. var_dump(trim($introtext)); // this is tidier, with leading/trailing whitespace characters removed
  17. var_dump(trim($description)); // this is tidier, with leading/trailing whitespace characters removed
  18.  
  19. echo "n---n";
  20.  
  21. list($introtext, $description) = preg_split('~s*<hr id="system-readmore" />s*~', $html, 2);
  22. var_dump($introtext); // no trim() call, no leading/trailing whitespace characters displayed
  23. var_dump($description); // no trim() call, no leading/trailing whitespace characters displayed
  24.  
  25. string(22) "Some text yatta yatta
  26. "
  27. string(25) "
  28. Some more text blah blah"
  29.  
  30. ---
  31. string(21) "Some text yatta yatta"
  32. string(24) "Some more text blah blah"
  33.  
  34. ---
  35. string(21) "Some text yatta yatta"
  36. string(24) "Some more text blah blah"
Add Comment
Please, Sign In to add comment