kev@num Posted September 7, 2007 Share Posted September 7, 2007 hello, i have MySQL version 4.1.11, PHP Version: 4.4.6... anyway, i have a stored in mysql paragraphs like this:- Double Zero - Rythm Beater / Immaculate Conception Double Zero strike back (just like the Empire did) with some sleazy Jump Up funk, imagine immersing yourself in a tub full of pheromones before donning a proper pimp suit and going out on the pull. Well that’s precisely what ‘Rhythm Beater’ has done, and it’s got hyped up ladies literally dripping off it. ‘Immaculate Conception’ must be what they told the aforementioned women’s fathers… anyway, it’s jammed full of more sexual chemistry that’ll make any self respecting Lady Junglist get her knickers in a knot. Nice i need the data in mysql to stay like this, however sometimes when i retreive the information i would like to ignore the first line (the title) and just show the paragraph.. does this sound like something that's possible? at the moment, i'm pulling the data like this: $query_Recordset2 = sprintf("select products_description from products_description where products_id = %s", $colname_Recordset2); and then shortening the paragraph to 350 characters like this: function shorten( $str, $num = 350 ) { if( strlen( $str ) > $num ) $str = substr( $str, 0, $num ) . "..."; return $str; } does anyone know the best way, if at all that i can trim off the first line? either by the mysql select statement or the php function shorten? thanks in advance kev. oh ps, i also use this function to convert the line breaks into readable format: function nl2brStrict($text, $replacement = '') { return preg_replace("((\r)+)", trim($replacement), $text); // return preg_replace("((\r\n)+)", trim($replacement), $text); } Quote Link to comment https://forums.phpfreaks.com/topic/68341-trim-off-first-line-from-string/ Share on other sites More sharing options...
GingerRobot Posted September 7, 2007 Share Posted September 7, 2007 Sure, explode by the new line: <?php $str = 'Double Zero - Rythm Beater / Immaculate Conception Double Zero strike back (just like the Empire did) with some sleazy Jump Up funk, imagine immersing yourself in a tub full of pheromones before donning a proper pimp suit and going out on the pull. Well that’s precisely what ‘Rhythm Beater’ has done, and it’s got hyped up ladies literally dripping off it. ‘Immaculate Conception’ must be what they told the aforementioned women’s fathers… anyway, it’s jammed full of more sexual chemistry that’ll make any self respecting Lady Junglist get her knickers in a knot. Nice'; list($title,$blank_line,$content) = explode("\n",$str); echo $content; ?> $title would have the title in, $blankline is just a placeholder if you like, since there is a blank line. Quote Link to comment https://forums.phpfreaks.com/topic/68341-trim-off-first-line-from-string/#findComment-343627 Share on other sites More sharing options...
kev@num Posted September 7, 2007 Author Share Posted September 7, 2007 ooh 1000 thankyous it works, and is so simple i think i might have to visit here again!! kev. Quote Link to comment https://forums.phpfreaks.com/topic/68341-trim-off-first-line-from-string/#findComment-343640 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.