|
 |
|
เลขบัตรประจำตัวประชาชน การเว้นวรรค เลขบัตรประจำตัวประชาชน ถ้าต้องการเว้นวรรค โดยเอาตัวเลขจากดาต้าเบสมาแสดง ต้อง echo ยังไงคับ |
|
 |
|
|
 |
 |
|
ในเบสเก็บเป็นแบบไหนอ่ะครับ
|
 |
 |
 |
 |
Date :
2009-08-24 09:47:22 |
By :
sillyman24 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ลองใช้แบบนี้ดูครับเป็นการแทนตัว - ให้เป็นค่าว่างนะครับ
$Nemp_idcard= str_replace("-"," ",$emp_idcard);
|
 |
 |
 |
 |
Date :
2009-08-24 10:21:36 |
By :
manop_cs |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ในด้าต้าเบสควรเก็บแบบไหนคับ ผมเก็บไว้ 13 หลักพอดีคับ
เป็น int
ส่วนการเว้นวรรค ต้องการจะเอามาใช้ในหน้าที่แสดงรายการอ่าครับ
|
 |
 |
 |
 |
Date :
2009-08-24 10:43:13 |
By :
tanuwate |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
$emp_idcard=$result[emp_idcard];
echo"emp_idcard";
ตอนรันออกมาเป็นแบบนี้ ครับ 1111111111111
อยากให้มันเป็น 1-1111-11111-11-1
ขอโทษด้วย เขียนหัวข้อผิดเลย
|
 |
 |
 |
 |
Date :
2009-08-24 10:54:35 |
By :
tanuwate |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ผมลองเขียนให้นะครับไม่รู้ยาวไปเปล่าแต่มันก็แสดงผลได้ ยังไงก็ไปเขียนเป็น Function เองนะครับ
Code (PHP)
<?php
$var = '1222233333445';
$srt[0] = substr($var, 0, 1);
$srt[1] = substr($var, 1, 4);
$srt[2] = substr($var, 5, 5);
$srt[3] = substr($var, 10, 2);
$srt[4] = substr($var, 12, 1);
echo $srt[0]."-".$srt[1]."-".$srt[2]."-".$srt[3]."-".$srt[4];
?>
|
 |
 |
 |
 |
Date :
2009-08-24 13:24:31 |
By :
ariya99 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ไหนๆก็ไหนๆแล้วครับ แบบ Function
Code (PHP)
<?php
function FnID($var)
{
$srt[0] = substr($var, 0, 1);
$srt[1] = substr($var, 1, 4);
$srt[2] = substr($var, 5, 5);
$srt[3] = substr($var, 10, 2);
$srt[4] = substr($var, 12, 1);
return $srt[0]."-".$srt[1]."-".$srt[2]."-".$srt[3]."-".$srt[4];
}
echo FnID("1222233333445");
?>
|
 |
 |
 |
 |
Date :
2009-08-24 14:15:32 |
By :
ariya99 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอขอบคุณมากเลยนะคับท่าน ABITz แร้วก็ท่านอื่น ๆ ด้วยนะคับ ที่ช่วยชี้แนะ
|
 |
 |
 |
 |
Date :
2009-08-24 14:58:40 |
By :
tanuwate |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
เปลี่ยนเป็น +1 ได้มั๊ยครับ อิอิ จะได้ มี บั่ง กะเค้ามั่ง   
|
 |
 |
 |
 |
Date :
2009-08-24 15:06:50 |
By :
ariya99 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
บวก 1 ทำไงคับ เด๋วจัดให้ ฮ่าๆๆ ทำไม่เป็น
|
 |
 |
 |
 |
Date :
2009-08-24 15:08:27 |
By :
tanuwate |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
คลิกตรง ให้คะแนน ที่อยู่ใต้รูปผมอะครับ
|
 |
 |
 |
 |
Date :
2009-08-24 15:18:01 |
By :
ariya99 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 03
|