Juszeil Conception

Juszeil Conception

  • 主 頁
  • 部 落 格
  • 相 簿
  • 關 於
  • 更 新 資 訊
  • 網站地圖

«2017 - 3»
日一二三四五六
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
TODAY

Hide Banner | LOGIN
2023-3-21 |

BLOG 部落格

Total found 1 articles on 2017-3-25.

蝔 撘 隤 閮 2017-3-25 18:32:21

PHP String Chopping Excerpt



$string = 'Lor em ipsum dolor sit #hastag amet, consectetur adipiscing elit. Sed metus augue, mollis non ornare eget, consectetur non eros. In hac habitasse platea dictumst. Duis egestas ultricies iaculis';
$before = 10;
$after = 10;
$find = '#hastag';

$pos = strpos($string, $find);

$start = $pos - $before; // work out where to start
$length = $start + $after + strlen($find) - 2; // work out where to end

$start = max($start, 0); // make sure we don't start before the beginning of the string
$length = min($length, strlen($string)); // make sure we don't end after the end of the string

$new = substr($string, $start, $length);

echo $new;

?>


Relate Post : PHP - run on background PHP - header:銝頛頧蝑蝑 PHP - 憒雿曉箏拙交撌桐憭撠"隞" PHP - APC module Web Cache 雿輻沌HP导亙导慢SV隞 PHP - 憒雿霈 PHP Y(array) 頧 JavaScript 臭誑雿輻函拐辣(Object)澆 ( json_encode() 頧 Linux / UNIX Setup and Run PHP Script As A Cron Job PHP - Install CURL on linux platform PHP - 芷文銝脤剖偏嚗銝憭嚗孵摮 (拍 trim ) PHP - 憒雿Y頝典僑摨衣隞質”
Comments :
No Comments

Post your comment:


Post your comment by Guest :
Verify Code :


Back To Top

Find Me

Powered By 2013-2015 ©. Juszeil Conception version 2.0
Queries Executed : 0.01 seconds