strtolower() 字符串轉為小寫 <?php $str="Mary Had A Little Lamb and She LOVED It So"; $str=strtolower($str); echo $str; // Prints mary had a little lamb and she loved it so ?>
strtoupper() 字符串轉為大寫 <?php $str = "Mary Had A Little Lamb and She LOVED It So"; $str = strtoupper($str); echo $str; // Prints MARY HAD A LITTLE LAMB AND SHE LOVED IT SO ?>
strpos() 尋找字符串中某字符最先出現的位置 <?php $mystring = 'abc'; $findme = 'a'; $pos = strpos($mystring, $findme); // Note our use of ===. Simply == would not work as expected // because the position of 'a' was the 0th (first) character. if ($pos === false) { echo "The string '$findme' was not found in the string '$mystring'"; } else { echo "The string '$findme' was found in the string '$mystring'"; echo " and exists at position $pos"; } ?>
<?php $fp=fopen("example.txt","r"); while ($line=fets($fp)) { echo "$line<br>"; } fclose($fp); }
練習 1. 先將下列文章建立成文字檔
The objective of Department of Information Management is to train excellent people with good skills both in information technology and business management. We also request the students to acquire at least four recognized certificate before they graduate. All of our faculty members have master degrees or above. Their researches focus on all subjects of the newest technology of Information Management Systems. Besides, some faculty members have practical working experiences in MIS industries. This helps us to provide students not only theoretical knowledge but also practical experiences.