|
|
| 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 | |
|
|
|
การใช้งานฟังก์ชั่น strpos ใน PHP |
|
การใช้งาน ฟังก์ชั่น strpos
รายละเอียด :
ฟังก์ชั่นนี้ มีหน้าที่ค้นหาตำแหน่งของ string ครับ เมื่อเรียกใช้ฟังก์ชั่น strpos ถ้าฟังก์ชั่นนี้ทำงานสำเร็จจะ return ค่าตำแหน่งของ string ที่เราค้นหาคืนมา แต่ถ้าหาไม่เจอจะ return ค่า FALSE กลับมาครับ ดูตามตัวอย่างเลยครับ
//ตัวอย่างการใช้งานฟังก์ชั่น strpos
$string = 'blog.deveak.com'; $find = 'a'; $pos = strpos($string, $find);
//ถ้าไม่เจอจะคือค่า FALSE กลับมา if ($pos === false) { echo "The string '$find' was not found in the string '$string'"; } else { echo "The string '$find' was found in the string '$string'"; echo " and exists at position $pos"; }
?>
Create Date : 07 สิงหาคม 2551 |
Last Update : 7 สิงหาคม 2551 19:37:36 น. |
|
0 comments
|
Counter : 850 Pageviews. |
|
|
|
|
|
|
|
|