http://www.codebit.cn/pub/html/php_mysql/tip/data/sort_array/ <?php// 说明:PHP中二维数组的排序方法 /** * @package BugFree * @version $Id: FunctionsMain.inc.php,v 1.32 2005/09/24 11:38:37 wwccss Exp $ * * * Sort an two-dimension array by some level two items use array_multisort() function. * * sysSortArray($Array,"Key1","SORT_ASC","SORT_RETULAR","Key2"……) * @author Chunsheng Wang <[email protected]> * @param array $ArrayData the array to sort. * @param string $KeyName1 the first item to sort by. * @param string $SortOrder1 the order to sort by("SORT_ASC"|"SORT_DESC") * @param string $SortType1 the sort type("SORT_REGULAR"|"SORT_NUMERIC"|"SORT_STRING") * @return array sorted array. */function sysSortArray($ArrayData,$KeyName1,$SortOrder1 = "SORT_ASC",$SortType1 = "SORT_REGULAR") { if(!is_array($ArrayData)){ return $ArrayData; }
// Get args number. $ArgCount = func_num_args();
// Get keys to sort by and put them to SortRule array. for($I = 1;$I < $ArgCount;$I ++){ $Arg = func_get_arg($I); if(!eregi("SORT",$Arg)){ $KeyNameList[] = $Arg; $SortRule[] = '$'.$Arg; }else{ $SortRule[] = $Arg; } } // Get the values according to the keys and put them to array.
foreach($ArrayData AS $Key => $Info){ foreach($KeyNameList AS $KeyName){ ${$KeyName}[$Key] = $Info[$KeyName]; } } // Create the eval string and eval it.
$data = array(array("filter_attr_name"=>'尺寸',"attr_list"=>array('attr_value'=>'全部')),array("filter_attr_name"=>'尺寸大小大',"attr_list"=>array('attr_value'=>'全部')),array("filter_attr_name"=>'尺寸大小',"attr_list"=>array('attr_value'=>'全部')));
我给这个数组排序,按照filter_attr_name的长度来排序,希望有人给帮帮忙,自己写了个,不好使
usort($data, 'sortByLen');function sortByLen($a, $b) { if (strlen($a['filter_attr_name']) == strlen($b['filter_attr_name'])) { return 0; } else { return (strlen($a['filter_attr_name']) > strlen($b['filter_attr_name'])) ? 1 : -1; }}
http://www.codebit.cn/pub/html/php_mysql/tip/data/sort_array/
<?php// 说明:PHP中二维数组的排序方法 /**
* @package BugFree
* @version $Id: FunctionsMain.inc.php,v 1.32 2005/09/24 11:38:37 wwccss Exp $
*
*
* Sort an two-dimension array by some level two items use array_multisort() function.
*
* sysSortArray($Array,"Key1","SORT_ASC","SORT_RETULAR","Key2"……)
* @author Chunsheng Wang <[email protected]>
* @param array $ArrayData the array to sort.
* @param string $KeyName1 the first item to sort by.
* @param string $SortOrder1 the order to sort by("SORT_ASC"|"SORT_DESC")
* @param string $SortType1 the sort type("SORT_REGULAR"|"SORT_NUMERIC"|"SORT_STRING")
* @return array sorted array.
*/function sysSortArray($ArrayData,$KeyName1,$SortOrder1 = "SORT_ASC",$SortType1 = "SORT_REGULAR")
{
if(!is_array($ArrayData)){
return $ArrayData;
}
// Get args number.
$ArgCount = func_num_args();
// Get keys to sort by and put them to SortRule array.
for($I = 1;$I < $ArgCount;$I ++){
$Arg = func_get_arg($I);
if(!eregi("SORT",$Arg)){
$KeyNameList[] = $Arg;
$SortRule[] = '$'.$Arg;
}else{
$SortRule[] = $Arg;
}
} // Get the values according to the keys and put them to array.
foreach($ArrayData AS $Key => $Info){
foreach($KeyNameList AS $KeyName){
${$KeyName}[$Key] = $Info[$KeyName];
}
} // Create the eval string and eval it.
$EvalString = 'array_multisort('.join(",",$SortRule).',$ArrayData);';
eval ($EvalString);
return $ArrayData;
}
// 示例 $arr = array(
array(
'name' => '学习',
'size' => '1235',
'type' => 'jpe',
'time' => '1921-11-13',
'class' => 'dd',
),
array(
'name' => '中国功夫',
'size' => '153',
'type' => 'jpe',
'time' => '2005-11-13',
'class' => 'jj',
),
array(
'name' => '编程',
'size' => '35',
'type' => 'gif',
'time' => '1997-11-13',
'class' => 'dd',
),
array(
'name' => '中国功夫',
'size' => '65',
'type' => 'jpe',
'time' => '1925-02-13',
'class' => 'yy',
),
array(
'name' => '中国功夫',
'size' => '5',
'type' => 'icon',
'time' => '1967-12-13',
'class' => 'rr',
),
); print_r($arr); //注意:按照数字方式排序时 153 比 65 小//$temp = sysSortArray($arr,"name","SORT_ASC","type","SORT_DESC","size","SORT_ASC","SORT_STRING");
$temp = sysSortArray($arr,"name","SORT_ASC");print_r($temp);
?>
一周至少六天班,每天最早八点下班。
PHP不是主要用到的,C++/AS才是,公司就一个PHP
资转正后2K。
其实也没聊什么,就是他告诉我说,没不用MVC模式来写PHP,电脑还仍旧是WIN的,只能算个PHP初级者
其实我觉得他并不对。不一定非得要用MVC来写PHP才可以运行。个人那种熟悉才是最好。另外PHP都必须得在linux才可以运行吗?WIN的一样的。不过MVC和linux我确实不熟,不熟悉。
同做PHP,顶楼主下吧,同情,国内工资太低了,还老加班,最重要的是没啥前途- -
我做的一个东西 www.pjob.info ,代码以及文件夹结构:www.pjob.info/code/
<?php
/**
*
* SOAP
* @Created 2010-11-2下午03:17:13
* @name soap.php
* @author [email protected]
* @version 1.0
* @version $Id:soap.php ,v 1.0 下午03:17:13 jc Exp
*/
set_time_limit(0);
ini_set('max_execution_time', '180');
header("Content-Type: text/html; charset=gb2312");
date_default_timezone_set('PRC');
define('soap_user', 'yuqiao');
define('soap_passwd', '89116037');
define('soap_type', 'Z_O_AWS_PRF_C_CQ');
define('e_str', 'StationNum,RainHourTotal');
define('s_str', '*');
$start_time = '201001020200'; //20 02 08 14
$end_time = '201001020800';
echo '开始时间:'.date('Y-m-d H:i',strtotime($start_time)).'-------------------------------------结束时间:'.date('Y-m-d H:i',strtotime($end_time)).'<br><p>';
$res = getSoap($start_time, $end_time);//print_r($res);/**
* getSoap
* 获取降雨量
* @param $start_time 开始时间
* @param $end_time 结束时间
* @param $style 分割样式
* */
function getSoap($start_time, $end_time, $style='<br>'){
$client = new SoapClient("http://********/hmsas/wsdl/hmsas.wsdl",array('encoding'=>'gb2312'));
$format_starttime = date('Y-m-d',strtotime($start_time)); //开始时间格式化为: 年-月-日
$format_endtime = date('Y-m-d',strtotime($end_time)); //结束时间格式化为:年-月-日
$day = abs((strtotime($format_endtime)-strtotime($format_starttime))/86400); //相差天数
$i = 0;
$t = 1;
if (!$day){ //一天中情况
$key = 24-(int)(date('G',strtotime($start_time))); //计算是否为
$p = ceil(((int)(date('G',strtotime($end_time)))+$key)/6); //此时间在一天中的时间段
$tmp = 0; //临时变量
while ($tmp < $p){
$e_time = date('YmdHi',strtotime($start_time)+3600*6); //当前时间加6小时为一个时间段
echo '-------------------aaa-------------'.date('Y-m-d H:i',strtotime($start_time)).'-------'.date('Y-m-d H:i',strtotime($e_time)).'----------------------------------'."<br>";
echo $start_time.'<br>';
echo $e_time;
echo '>>>>>>>>>>>><br>';
$resultdata=$client->rainaddupdata(soap_type, $start_time, $e_time,e_str, s_str, soap_user, soap_passwd);
foreach ($resultdata as $k=>$v){
echo $v.'<br>';
}
$tmp++;
$s_time = $start_time = $e_time;
if ((int)($t/4)==1){
echo "<p>";
$t =0;
}
$t++;
}
}
while ($i<$day){
$key = 24-(int)(date('G',strtotime($start_time))); //计算是否为
if (intval($day)==1) // 等于1天的情况
{
$p = ceil(((int)(date('G',strtotime($end_time)))+$key)/6); //此时间在一天中的时间段
$tmp = 0; //临时变量
while ($tmp < $p){
$e_time = date('YmdHi',strtotime($start_time)+3600*6); //当前时间加6小时为一个时间段
echo '-------------------aaa-------------'.date('Y-m-d H:i',strtotime($start_time)).'-------'.date('Y-m-d H:i',strtotime($e_time)).'----------------------------------'."<br>";
echo $start_time.'<br>';
echo $e_time;
echo '>>>>>>>>>>>><br>';
$resultdata=$client->rainaddupdata(soap_type, $start_time, $e_time,e_str, s_str, soap_user, soap_passwd);
foreach ($resultdata as $k=>$v){
echo $v.'<br>';
}
$tmp++;
$s_time = $start_time = $e_time;
if ((int)($t/4)==1){
echo "<p>";
$t =0;
}
$t++;
}
}elseif (intval($day) > 1) // 大于1天的情况
{
$sss = date('Y-m-d',strtotime($end_time)); //结束时间
$ssss = date('Y-m-d',strtotime($start_time)); //当前时间
if (abs((strtotime($sss)-strtotime($ssss))/86400) == 1){ //结束时间-当前时间=倒数最后一天 的情况分别进行处理
$p = ceil(((int)(date('G',strtotime($end_time)))+$key)/6); //一天中的时间段
for ($s=0;$s<$p;$s++){
echo date('Y-m-d H:i',strtotime($start_time)).'-----bbb---------'.date('Y-m-d H:i',strtotime($start_time)+3600*6).'<br>';
$start_time = date('YmdHi',strtotime($start_time)+3600*6);
}
}else{ //多天情况
for ($s=0;$s<4;$s++){ //一天4个时间段
echo date('Y-m-d H:i',strtotime($start_time)).'------ccc--------'.date('Y-m-d H:i',strtotime($start_time)+3600*6).'<br>';
$start_time = date('YmdHi',strtotime($start_time)+3600*6);
}
echo '<p>';
}
}
$i++;
}
}
?>
一个时间段就可以 多加一个时间段APACHE就死了....