PHP ver gevorderde |
|
function short($sContent, $iSize, $sSplit = ' '){
if(strlen($sContent) <= $iSize){
return $sContent;
}
else{
$aTmp = explode($sContent, $sSplit);
$sNew = '';
$iTotLen = 0;
$iCount = count($aTmp);
for($i=0; $i<$iCount; $i++){
$iTotLen += strlen($aTmp[i]);
if($iTotLen > $iSize){
break;
}
$sNew .= $aTmp[i] . $sSplit;
}
return $sNew;
}
}
$iLen = ceil(strlen($sContent)/2);
$sContent1 = short($sContent, $iLen);
$sContent2 = str_replace($sContent1, "", $sContent);
function short($sContent, $iSize, $sSplit = ' '){ if(strlen($sContent) <= $iSize){ return $sContent; } else{ $aTmp = explode($sContent, $sSplit); $sNew = ''; $iTotLen = 0; for($i=0; $i<$iCount; $i++){ if($iTotLen > $iSize){ break; } $sNew .= $aTmp[i] . $sSplit; } return $sNew; } } $sContent1 = short($sContent, $iLen);
zoeits, niet getest, hoort maar te werken van de eerste keer |