دالة PHP chunk_split ()
مثال
قسّم السلسلة بعد كل حرف وأضف "." بعد كل انقسام:
<?php
$str = "Hello world!";
echo chunk_split($str,1,".");
?>
التعريف والاستخدام
تقسم الدالة chunk_split () سلسلة إلى سلسلة من الأجزاء الأصغر.
ملاحظة: هذه الوظيفة لا تغير من السلسلة الأصلية.
بناء الجملة
chunk_split(string,length,end)
قيمه المعامل
Parameter | Description |
---|---|
string | Required. Specifies the string to split |
length | Optional. A number that defines the length of the chunks. Default is 76 |
end | Optional. A string that defines what to place at the end of each chunk. Default is \r\n |
تفاصيل تقنية
قيمة الإرجاع: | إرجاع السلسلة المنقسمة |
---|---|
إصدار PHP: | 4+ |
مزيد من الأمثلة
مثال
قسّم السلسلة بعد كل حرف سادس وأضف "..." بعد كل تقسيم:
<?php
$str = "Hello world!";
echo chunk_split($str,6,"...");
?>
❮ مرجع سلسلة PHP