Új hozzászólás Aktív témák
-
DNReNTi
őstag
válasz
spammer
#13456
üzenetére
Sajnos már nem tudom szerkeszteni amit írtam... megcsináltam függvénynek és kicsit tuningoltam rajta, így még jobb és könnyebb használni:
function cutText($text, $needle) {
$result = '';
$difference = 100;
$needle_length = strlen($needle);
$needle_position = stripos($text, $needle);
if ($needle_position){
$text_tmp = substr($text, 0, $needle_position);
if (strlen($text_tmp) > $difference) {
$text_tmp = substr($text_tmp, -$difference);
$space_position = strpos($text_tmp, ' ');
$text_tmp = '...' . substr($text_tmp, $space_position+1);
}
$result = $text_tmp;
$text_tmp = substr($text, $needle_position, ($needle_position+$needle_length+$difference));
if (strlen($text_tmp) > $difference) {
$space_position = strpos($text_tmp, ' ', $difference);
$text_tmp = substr($text_tmp, 0, $space_position) . '...';
}
$result = $result . $text_tmp;
} else {
$result = 'A keresés nem hozott eredményt!';
}
return $result;
}Használata egyszerűen csak:
echo cutText($text, $needle);
Új hozzászólás Aktív témák
- Asus ROG Scar 18 - RTX 5090 - 64GB Ram 2x2TB SSD
- Bomba ár! Dell Vostro 5620 - i5-1240P I 8GB I 256SSD I 16" WUXGA I Cam I W11 I Garancia!
- Bomba ár! Dell Vostro 15 3515 - Ryzen 5 I 8GB I 256SSD I 15,6" FHD I Cam I W11 I Garancia!
- Bomba ár! Lenovo IdeaPad V110 - i5-6GEN I 8GB I 128SSD I 15,6" HD I HDMI I Cam I W10 I Gari!
- Bomba ár! HP Pavilion 15 - i5-4GEN I 8GB I 750GB I 15,6" HD Touch I Cam I W10 I Garancia!
- BESZÁMÍTÁS! Microsoft XBOX Series S 512GB játékkonzol garanciával hibátlan működéssel
- Okosóra felvásárlás!! Samsung Galaxy Watch 5 Pro, Samsung Galaxy Watch 6 Classic
- BESZÁMÍTÁS! Asrock B450M R7 2700 16GB DDR4 512GB SSD GTX 1660 Super 6GB ZALMAN S4 FSP 500W
- HP OMEN Transcend 2.8K OLED / Ultra 7 155H / RTX4060 8GB / 16GB 7467MHz / 1TB NVMe! BeszámítOK
- Dell Latitude 5411,14",FHD,i7-10850H,16GB DDR4,512GB SSD,2GB VGA,WIN11
Állásajánlatok
Cég: Laptopműhely Bt.
Város: Budapest

