"ID","NAME","AGE"
"1","polo","18"
"2","tony","20"
"3","jack","19" input.txt
Ïòinput.txtÖÐÌí¼ÓÒ»ÁÐCONTENTֵΪ1,2,3ÈçºÎʵÏÖ
PHP code:
<?php
$sContent = file_get_contents("input.txt");
$iFirst = stripos($sContent, "\n");
$sFirst = substr($sContent, 0, $iFirst-1) . ',"CONTENT"' . "\n";
$iSecode = stripos($sContent, "\n", $iFirst+strlen('\n'));
$sSecode = substr($sContent, $iFirst+strlen('\n')-1, $iSecode-$iFirst-strlen('\n')) . ',"1"'. "\n";
$iThird = stripos($sContent, "\n", $iSecode+strlen('\n'));
$sThird = substr($sContent, $iSecode+strlen('\n')-1, $iThird-$iSecode-strlen('\n')) . ',"2"'. "\n";
$sFour = substr($sContent, $iThird+strlen('\n')-1, -1) .',"3"'. "\n";
echo $sFirst . $sSecode . $sThird . $sFour;
file_put_contents("input.txt", $sFirst . $sSecode . $sThird . $sFour);
?>
¿É³ÖÐøÍùÿÐкó×·¼Ó£¬´Ë¶Î¿ÉÓÃÑ»·¸Äд
$s = <<< TEXT
"ID","NAME","AGE"
"1","polo","18"
"2","tony","20"
"3","jack","19"
TEXT;
ÔÚ¹úÍâµÄ¿Õ¼ä£¬ÆäËüµÄphpÕ¾µã¶¼Õý³££¬¿ÉÖ»ÓÐ×î½ü½¨µÄÕâ¸öÕ¾µã£¬Ö»ÒªÒ»ä¯ÀÀphpÎļþ¾Í³öÏÖÏÂÔØÌáʾ£¬ÏÂÔØÏÂÀ´µÄÎļþ¶¼ÊÇ´øÓÐphpÔ´Â룬¸÷λ·¹ýµÄ£¬°ï°ïÎÒ£¬¿´¿´Ê²Ã´ÔÒò£¬ÏÈлÁË¡£
¿Õ¼ä²»Ö§³Ö¡£
»òÕßÄãµÄÕ˺ÅûÓп ......
ÎÒ¸ÕѧϰphpÇëÎÊ£¬Èç¹ûÎÒ°ÑphpÎļþÉÏ´«ÖÁ·þÎñÆ÷ºó£¬ÀýÈçhttp://www.****.com/cast.phpÕâ¸öÎļþ»á²»»á±»±ðÈËÏÂÔØ»ò¸´Öư¢£¿
¿ÉÒÔ±»ÏÂÔØ£¬Ò²¿ÉÒÔ²»±»ÏÂÔØ£¬¿´web·þÎñÆ÷¶Ô¸ÃÎļþȨÏÞµÄÅäÖÃ
¿´Äã¶ÔÎļþȨÏÞµÄÉèÖÃ
......