|
|
|
รับไฟล์ text เข้ามาแล้วแสดงออกบนหน้าจอ โดยเปลี่ยนสีตัวอักษร |
|
|
|
|
|
|
|
Code (PHP)
<?php
//สมมุติไฟล์อยู่ใน $str แล้วนะครับ
$str='adsasdbasdascd';
$array=array('a','b','c');
$str2='';
foreach($array as $letter){
$str2.=str_ireplace($letter,"<span style='color:red;'>{$letter}</span>",$str);
}
echo $str2;
?>
|
|
|
|
|
Date :
2012-01-19 09:05:19 |
By :
thaicloud |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
<?php
$str= fopen("Sample.txt","r");
$array=array('a','e','i','o','u');
$str2= '';
foreach($array as $letter){
$str2.=str_ireplace($letter,"<span style='color:blue;'>{$letter}</span>",$str);
}
echo $str2;
?>
ผมเขียนถูกหรือยังอ่ะคับ ทำไมโปรแกรมไม่อ่านไฟล์ผมเลย
|
|
|
|
|
Date :
2012-01-19 10:18:24 |
By :
hnongpor |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
<?php
$filename = "Sample.txt";
$handle = fopen($filename, "r");
$str1 = fread($handle, filesize($filename));
$array=array('a','b','c');
$str2='';
foreach($array as $letter){
$str2.=str_ireplace($letter,"<span style='color:red;'>{$letter}</span>",$str1);
}
echo $str2;
fclose($handle);
?>
|
|
|
|
|
Date :
2012-01-19 11:23:53 |
By :
thaicloud |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code
<?php
$f=fopen("Sample.txt","r");
if($f){
while (!feof($f)){
$lines[] = fgets($f,4096);
}
fclose($f);
}
echo"<html><title>Somewhere over the rainbow,</title><body>";
$vowels = array("a","e","i","o","u","A","E","I","O","U");
$result = false;
foreach ($line as $aLine){
for($i=0;$i<strlen($aLine);$i++)
{ $result = false;
for($j=0;$j<sizeof($vowels);$j++)
{ $result = ($aLine[$i] == $vowels[$j]);
if($result)
echo '<font size="3" color="blue">'.$aLine[$i].'</font>';
if(!$result)
echo $aLine[$i];
}
echo'</br>';
}
echo"</body></html>"; ?>
ช่วยตรวจสอบคำสั่งนี้ให้ทีคับ
มันผิดตรงไหน
|
|
|
|
|
Date :
2012-01-19 14:21:15 |
By :
hnongpor |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code
<?php
$f=fopen("Sample.txt","r");
if($f){
while (!feof($f)){
$lines[] = fgets($f,4096);
}
fclose($f);
}
echo"<html><title>Somewhere over the rainbow,</title><body>";
$vowels = array("a","e","i","o","u","A","E","I","O","U");
$result = false;
foreach ($line as $aLine){
for($i=0;$i<strlen($aLine);$i++)
{ $result = false;
for($j=0;$j<sizeof($vowels);$j++)
{ $result = ($aLine[$i] == $vowels[$j]);
if($result)
echo '<font size="3" color="blue">'.$aLine[$i].'</font>';
if(!$result)
echo $aLine[$i];
}
echo'</br>';
}
echo"</body></html>"; ?>
ช่วยตรวจสอบคำสั่งนี้ให้ทีคับ
มันผิดตรงไหน
|
|
|
|
|
Date :
2012-01-19 14:21:36 |
By :
hnongpor |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<?php
$f=fopen("Sample.txt","r");
if($f){
while (!feof($f)){
$lines[] = fgets($f,4096);
}
fclose($f);
}
echo"<html><title>Somewhere over the rainbow,</title><body>";
$vowels = array("a","e","i","o","u","A","E","I","O","U");
$result = false;
foreach ($line as $aLine){
for($i=0;$i<strlen($aLine);$i++)
{ $result = false;
for($j=0;$j<sizeof($vowels);$j++)
{ $result = ($aLine[$i] == $vowels[$j]);
if($result)
echo '<font size="3" color="blue">'.$aLine[$i].'</font>';
if(!$result)
echo $aLine[$i];
}
echo'</br>';
}
echo"</body></html>"; ?>
คำสั่งนี้ผิดยังไงหรอครับ
ช่วยตรวจสอบให้ที
|
|
|
|
|
Date :
2012-01-19 14:23:08 |
By :
hnongpor |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
echo'</br>';
}
}
echo"</body></html>"; ?>
|
|
|
|
|
Date :
2012-01-19 14:45:46 |
By :
ridtichai |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Date :
2012-01-19 15:55:54 |
By :
ืเดื |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
<?php
$f=fopen("Sample.txt","r");
if($f){
while (!feof($f)){
$line[] = fgets($f,4096);
}
fclose($f);
}
echo"<html><title>Somewhere over the rainbow,</title><body>";
$vowels = array("a","e","i","o","u","A","E","I","O","U");
$result = false;
foreach ($line as $aLine){
for($i=0;$i<strlen($aLine);$i++){
$result = false;
for($j=0;$j<sizeof($vowels);$j++){
$result = ($aLine[$i] == $vowels[$j]);
if($result)
echo '<font size="3" color="blue">'.$aLine[$i].'</font>';
if(!$result)
echo $aLine[$i];
}
echo'</br>';
}
}
echo"</body></html>";
?>
แก้ต่อเองนะครับ
|
|
|
|
|
Date :
2012-01-19 19:05:04 |
By :
thaicloud |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 05
|