November 12, 200916 yr Hello! I'm making a blog, and I want to be able to manually set a cutoff point. For example, in the post, you put a <!-- more -->, just like in wordpress, and then you use preg_replace or something to change that and everything after it into a single "...". At the moment, I'm using a simple substr, but I'm worried that that might cut off an <img /> or something like that. Any advice, tips, tutorial or just straight up code? Here's how I'm parsing the code atm: $bodytext = stripslashes($a["post"]); $bodytext = substr($bodytext, 0, 500); $bodytext = "$bodytext..."; $bodytext = preg_replace("/\n/", "<br />", $bodytext);
November 12, 200916 yr Author You could just use explode() and set the delimiter to be your <!-- more --> would that look anything like this: $display = explode("<!-- more -->", $bodytext); $bodytext = $display[0];
November 12, 200916 yr Look on php.net/substr people have posted fairly useful functions for this very problem.
Create an account or sign in to comment