Hello
I have a small function, I have taken a dynamic drive tooltip script and everything works beautiful, the link too directs to the correct id number however the description is always the same, its always the same description.
in other words the variable $number is always the value of the first regex that it finds, how do i fix this? I am not that good yet with regular expression.
Short description: Basically what I do here is see if my data from the db which is inputted as $_blob has a tooltip: inside it, then I get the number and the rest is simple.
Funny thing is when i
count( $tooltipArray )
i get the correct number, but when i try and use a for loop its seems like everything is in one value which I guess makes sense since i am exploding tooltip: and not specifying an end.
function convertExternalLinks($_blob){
$toolTip = false;
if (ereg("tooltip:",$_blob)) {
$toolTip = true;
$tooltipArray = explode("tooltip:",$_blob);
$number = ereg_replace("\">.*","",$tooltipArray[1]);
/* echo count($tooltipArray);
for ($k = 0; $k < count($tooltipArray); $k++) {
echo $tooltipArray[$k].'<br>';
}*/
//exit();
/*****************
GET DESCRIPTION
******************/
include 'someConfigurationFile.php';
$sql = 'SELECT intro,id,category,heading FROM articles WHERE id = '.$number;
$rs = @mysql_query($sql,$conn);
$row = @mysql_fetch_assoc($rs);
if (strlen($row['intro']) > 200) {
$intro = strip_tags(substr($row['intro'],0,200)).'...';
} else $intro = $row['intro'];
$toolTipDescription = " onMouseover='ddrivetip(\"<b>$row[heading]</b> - $intro\",\"#F1F1F1\", 200)' onMouseout='hideddrivetip()');";
} else $toolTipDescription = '';
/***********************************************
REGULAR EXPRESSION TO GO TO THE PAGE LINK
*********************************************/
$patternToMatch = '/tooltip:/';
$patternNormal = 'http://tooltip:';
$patternReplace = 'faq.php?id=';
if (ereg($patternNormal ,$_blob)) {
$_blob = ereg_replace($patternNormal,$patternReplace,$_blob);
//$_blob = $finalText;
}
$exception = 'http://www.somedomain;
$internalDocConversion = "http://www.somedomain.com/docs/";
//convert all links in the string to have the external target HTML
$addToAll = str_ireplace('<a href=', '<a class="blue" target="_blank" ' .$toolTipDescription .' href=', $_blob);
//convert all exception links to not use external target HTML
$addToAll = str_ireplace('<a class="blue" target="_blank" ' . $toolTipDescription.' href="'.$exception, '<a href="'.$exception, $addToAll);
//convert all exception links to not use external target HTML
$addToAll = str_ireplace('<a href='.$internalDocConversion, '<a class="blue" target="_blank" '. $toolTipDescription. ' href='.$internalDocConversion, $addToAll);
return $addToAll;
}