Any Java or PHP gurus out there? I need a script!!!!!

General ShopSite user discussion

Any Java or PHP gurus out there? I need a script!!!!!

Postby VinceS » Sun Apr 15, 2007 10:25 am

I need a Java script or PHP app to return the first 100 words of the More Information Text and also strip out any HTML code.

So for instance the More Information Text....

<p><b>Top Notch Widgets</b> are the best widgets in the world.</p>

would be returned as

Top Notch Widgets are the best widgets in the world.

I've created a killer search results template and the only piece I can't get is a "condensed" product description. I'm willing to share the template it with whoever provides the script or I'll do it the the old fashion way and pay you for the code.
VinceS
 
Posts: 134
Joined: Fri Apr 06, 2007 1:26 pm

PHP Scripts

Postby topher » Sun Apr 15, 2007 10:46 am

We provide custom PHP programming.

Please contact us on monday morning, and we can discuss details.


-Chris
basiclink.com
topher
 
Posts: 15
Joined: Wed Dec 06, 2006 9:39 am
Location: San Diego, CA

Postby beley » Wed May 09, 2007 12:50 pm

This is really easy with PHP, just use a function to strip the HTML tags and truncate a certain number of characters:

Code: Select all
<?php


function truncate($text,$numb) {
$text = strip_tags($text);
$text = html_entity_decode($text, ENT_QUOTES);
if (strlen($text) > $numb) {
$text = substr($text, 0, $numb);
$text = substr($text,0,strrpos($text," "));
$etc = " ...";
$text = $text.$etc;
}
$text = htmlentities($text, ENT_QUOTES);
return $text;
}

$text = "<p>Lorem <em>ipsum</em> dolor sit <b>amet</b>, consectetur <em>adipisicing</em> elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>";

echo truncate($text, 40);


?>
Brandon Eley
Certified ShopSite Designer
beley
 
Posts: 111
Joined: Sun Aug 06, 2006 10:05 am
Location: LaGrange, GA


Return to User Forum

Who is online

Users browsing this forum: Bing [Bot] and 120 guests