[PHP] ช่วยเขียน reg ให้ด้วยครับ ตอนนี้ติดปัญหาไปไม่เป็น

เริ่มโดย workshop, 06 มีนาคม 2014, 14:20:13

หัวข้อก่อนหน้า - หัวข้อถัดไป

0 สมาชิก และ 1 ผู้มาเยือน กำลังดูหัวข้อนี้

workshop

PHP
ผมอยากตัด spacebar ออกจาก text นี้ครับ
หรือให้เปลี่ยนเป็น comma ติดกันก็ได้ เช่น
CHOTI,140305,2.50,2.54,85100,214790.00

ASIAN                140305       2.50       2.54       2.50       2.54        85100      214790.00
CHOTI                140305       0.00     230.00     229.00     229.00          700      160900.00
CM                   140305       4.40       4.42       4.38       4.40       346500     1527238.00


ขอบคุณครับ

คนธรรมดา

$str = str_replace(" ",",",'ASIAN                140305       2.50       2.54       2.50       2.54        85100      214790.00');
$strt = trim($str);
echo $strt;
[direct=https://www.hostkub.com/vps-server]เช่า vps[/direct]
[direct=https://www.hostkub.com/vps-server]เช่า server[/direct]

esanza.com

อ้างถึงจาก: คนธรรมดา ใน 06 มีนาคม 2014, 14:35:26
$str = str_replace(" ",",",'ASIAN                140305       2.50       2.54       2.50       2.54        85100      214790.00');
$strt = trim($str);
echo $strt;

ตามนี้ครับ  :wanwan016:
ใครต้องการเช่าโฮสที่มี Control Panel ดีๆ
และ Support ดี แนะนำ => [direct=https://support.hostatom.com/aff.php?aff=456]โฮสอะตอม[/direct]

คนธรรมดา

อ้างถึงจาก: esanza.com ใน 06 มีนาคม 2014, 14:36:41
อ้างถึงจาก: คนธรรมดา ใน 06 มีนาคม 2014, 14:35:26
$str = str_replace(" ",",",'ASIAN                140305       2.50       2.54       2.50       2.54        85100      214790.00');
$strt = trim($str);
echo $strt;

ตามนี้ครับ  :wanwan016:

ไม่ได้ test เดี่ยวเอาใหม่ครับ
[direct=https://www.hostkub.com/vps-server]เช่า vps[/direct]
[direct=https://www.hostkub.com/vps-server]เช่า server[/direct]

esanza.com

อ้างถึงจาก: คนธรรมดา ใน 06 มีนาคม 2014, 14:37:36
อ้างถึงจาก: esanza.com ใน 06 มีนาคม 2014, 14:36:41
อ้างถึงจาก: คนธรรมดา ใน 06 มีนาคม 2014, 14:35:26
$str = str_replace(" ",",",'ASIAN                140305       2.50       2.54       2.50       2.54        85100      214790.00');
$strt = trim($str);
echo $strt;

ตามนี้ครับ  :wanwan016:

ไม่ได้ test เดี่ยวเอาใหม่ครับ
โอ้ ผิดจริงๆด้วย
ใครต้องการเช่าโฮสที่มี Control Panel ดีๆ
และ Support ดี แนะนำ => [direct=https://support.hostatom.com/aff.php?aff=456]โฮสอะตอม[/direct]

workshop

อ้างถึงจาก: คนธรรมดา ใน 06 มีนาคม 2014, 14:37:36
อ้างถึงจาก: esanza.com ใน 06 มีนาคม 2014, 14:36:41
อ้างถึงจาก: คนธรรมดา ใน 06 มีนาคม 2014, 14:35:26
$str = str_replace(" ",",",'ASIAN                140305       2.50       2.54       2.50       2.54        85100      214790.00');
$strt = trim($str);
echo $strt;

ตามนี้ครับ  :wanwan016:


ไม่ได้ test เดี่ยวเอาใหม่ครับ

ขอบคุณครับ
กำลังจะตอบเลยว่ามันได้ , เต็มไปหมด^^

คนธรรมดา

$str = str_replace(" ",",",'ASIAN                140305       2.50       2.54       2.50       2.54        85100      214790.00');
$str = explode(",",$str);
foreach ($str as $value) {
   if($value!="") {
   echo $value.",";
   }
}
[direct=https://www.hostkub.com/vps-server]เช่า vps[/direct]
[direct=https://www.hostkub.com/vps-server]เช่า server[/direct]

workshop

อ้างถึงจาก: คนธรรมดา ใน 06 มีนาคม 2014, 14:46:05
$str = str_replace(" ",",",'ASIAN                140305       2.50       2.54       2.50       2.54        85100      214790.00');
$str = explode(",",$str);
foreach ($str as $value) {
   if($value!="") {
   echo $value.",";
   }
}

ขอบคุณครับ  :wanwan017: :wanwan017:
+1 ให้แล้วนะครับ

esanza.com


<?

$str_show=explode(' ','ASIAN                140305       2.50       2.54       2.50       2.54        85100      214790.00');
$text='';
for($i=0;$i<count($str_show);$i++){
if($str_show[$i]!=""){
$text.=$str_show[$i];
if($i!=count($str_show)-1){
$text.=",";
}else{
$text.='';
}
echo $text;
}
unset($text);
}
?>


อันนี้แถมครับ
ใครต้องการเช่าโฮสที่มี Control Panel ดีๆ
และ Support ดี แนะนำ => [direct=https://support.hostatom.com/aff.php?aff=456]โฮสอะตอม[/direct]