วันอาทิตย์ที่ 11 พฤษภาคม พ.ศ. 2557

20:36
ฟังก์ชัน substr_compare()
เปรียบเทียบสตริง ด้วยฟังก์ชัน substr_compare()



รูปแบบ
substr_compare(string1,string2,startpos,length,case)
string1 คือ สตริงแรก

string2 คือ สตริงที่2
startpos คือ ตำแหน่งเริ่มการเปรียบเทียบ
length คือ จำนวนตัวอักษรที่จะเปรียบเทียบ
case คือ กำหนดว่าจะเปรียบเทียบแบบ case-sensitive (DEFAULT) ใส่ค่า FALSE หรือ case-insensitiveใส่ค่า TRUE

ค่า return
0 - ถ้าสองสตริงเหมือนกัน
<0 - ถ้า string1 น้อยกว่า string2
>0 - ถ้า string1 มากกว่า string2 
ตัวอย่าง
<?php

echo substr_compare("Hello world","Hello world",0);

?>

ผลลัพธ์
0

0 ความคิดเห็น:

แสดงความคิดเห็น

:) :)) ;(( :-) =)) ;( ;-( :d :-d @-) :p :o :>) (o) [-( :-? (p) :-s (m) 8-) :-t :-b b-( :-# =p~ $-) (b) (f) x-) (k) (h) (c) cheer
Click to see the code!
To insert emoticon you must added at least one space before the code.