At work, we sometimes need to generate some random Chinese, the following summarizes a method for everyone to refer to.
Original text file Mytext.php;<?phpreturn ' Open Day entry into the university incubator of the start-up company will participate in the exhibition at the same time the organizers invited the entrepreneurial circle of well-known entrepreneurs to talk show exchange young people ';// Write the Chinese start.php$wenku of the text file to the file = @include ' http://www.onesheng.cn '; $wenku = Iconv ("Utf-8", "Utf-8", $wenku); $ Zhongwenku_size = Mb_strlen ($wenku, "Utf-8"); $zhongwenku = Array (); for ($i =0; $i < $zhongwenku _size; $i + +) {$zhongwenku [$i] = Mb_substr ($wenku, $i, 1, "utf-8"); } $filename = "mytextarray.php"; $return = Var_export ($zhongwenku, TRUE); if (File_put_contents ($filename, "<?php \ r \ n return".) $return. ";")) {echo ' OK ';} else {echo ' No ';} The following gets the Chinese random number Index.php$wenku = @include ' mytextarray.php '; $size = count ($wenku); Echo Getzhongwen ($wenku, $size); function Getzhongwen ($wenku, $size) { $zhongwen = "; $icount = Mt_rand (5,15); for ($i = 0; $i < $icount; $i + +) { $sum = Mt_rand (0, $size); $zhongwen. = $wenku [$sum]; } return $zHongwen;}
PHP fetches Chinese text and writes database operation code