1
需要我的PHP代碼來計算被回顯的文本中的字符。當這個數字達到64,我需要它回聲「$東西」,並從它停止的地方不斷迴應。通過計數字符回顯php分割回顯,添加可變內容,然後保持回顯
此外,最好的情況下這種代碼不應該裁剪完整的單詞。
例如
- 此:
echo 'This is a huge string that i mean to crop acording to it\'s character\'s count. For every 64 characters including spaces i need it to echo some other thing in the middle';
- 最終會是這樣的:
echo 'This is a huge string that i mean to crop acording to it\'s ' . $something . 'character\'s count. For every 64 characters including spaces ' . $something . 'i need it to echo some other thing in the middle';
爲了更好地理解......我需要這個代碼來解決這個事實該SVG文本不能被包裝和對齊。
您會使用mb_strimwidth嗎?怎麼樣?
在此先感謝!
---更新1 - 我已經嘗試過失敗
echo mb_strimwidth($row['resumen'], 0, 84, "$something");
echo mb_strimwidth($row['resumen'], 64, 64, "$something");
echo mb_strimwidth($row['resumen'], 128, 64, "$something");
---更新2 - 部分成功!
$uno = substr($row['resumen'], 0, 64);
$dos = substr($row['resumen'], 64, 64);
$tres = substr($row['resumen'], 128, 64);
$suma = $uno . "</text><text>" . $dos . "</text><text>" . $tres;
echo "$suma";
但這恰恰呼應我的文字的第一行。
你需要調查輸出緩衝。搜索Google搜索ob_start。 –
我試過..... echo mb_strimwidth($ row ['resumen'],0,84,「$ something」); echo mb_strimwidth($ row ['resumen'],64,64,「$ something」); echo mb_strimwidth($ row ['resumen'],128,64,「$ something」); –