<?php
/*=============================================================================
# FileName:base64.php
# Desc: Six room-pen test one: Read a file, encode it Base64, alphanumeric a newline in every 76 words
# Author:houyongzheng
# time:2013-05-20 14:25
=============================================================================*/
header (' content-type:text/html; Charset=utf-8 ');
$body =file_get_contents (' base64.txt ');
$base _body=base64_encode ($body);
$count =1;
For ($i =0 $i <strlen ($base _body); $i = $i +76) {
$index = ($count-1) *76;
@ $all _str.= ' <p> ' substr ($base _body, $index, 76). ' </p> ';
$count + +;
}
echo $all _str;
? >
<?php
/*=============================================================================
# FileName:array.php
# Desc: Six room pens question two: Write a function, the parameter is $n, generate an array, its element is 1~ $n, each element position randomly arranges, cannot repeat
# Author: Houyongzheng
# time:2013-05-20 15:01
============================================================= ================*/
function Rand_array ($n) {
$array =array ();
$rand _array=array ();
for ($i =1; $i <= $n; $i + +) {
Array_push ($array, $i);
}
return $array;
For ($i =0 $i <= ($n-1); $i + +) {
$rand =array_rand ($array, 1);
Array_push ($rand _array, $array [$rand]);
Unset ($array [$rand]);
}
return $rand _array;
}
Var_dump (Rand_array);
>