import flash.net.NetConnection;
import flash.net.NetStream;
import flash.net.URLRequest;
Server:red5 flash media server2-3 flashcom
import flash.net.NetStream;
import flash.net.URLRequest;
Server:red5 flash media server2-3 flashcom
arsort.php
result:
这个结论是正确的结果,但是假如我们的文件编码是gbk编码,而我们的输出键值是utf-8的编码,如:'1183888' '879126'是utf-8的字符串时候,那就会出现通过arsort排序出现错误的情况,于是我们只好这样:
foreach($userscoreinfo as $key =>$values)
{
$userscoreinfo[$key] = (int)$values;
}
强制转为int类型即可!!!
<?php
$str = array(1548940117=>'1183888',1377417885=>'879126');
print_r($str);
arsort($str);
print_r($str);
?>
$str = array(1548940117=>'1183888',1377417885=>'879126');
print_r($str);
arsort($str);
print_r($str);
?>
result:
0> php arsort.php
Array
(
[1548940117] => 1183888
[1377417885] => 879126
)
Array
(
[1548940117] => 1183888
[1377417885] => 879126
)
Array
(
[1548940117] => 1183888
[1377417885] => 879126
)
Array
(
[1548940117] => 1183888
[1377417885] => 879126
)
这个结论是正确的结果,但是假如我们的文件编码是gbk编码,而我们的输出键值是utf-8的编码,如:'1183888' '879126'是utf-8的字符串时候,那就会出现通过arsort排序出现错误的情况,于是我们只好这样:
foreach($userscoreinfo as $key =>$values)
{
$userscoreinfo[$key] = (int)$values;
}
强制转为int类型即可!!!
人生的快乐在于追逐你的敌人,抢夺他们的财物,搂抱他们的妻子——成吉思汗
都说社会主义发展是摸着石头过河,但怎么能摸着奶头过河呢?
虚无是上帝给予人最大的惩罚──他让人自己把自己剥夺得精光
对于这些农村的家庭而言,孩子不上学是等着穷,而孩子一上学那就是马上穷
有的人你看了一辈子,却忽视了一辈子;有的人你看了一眼,却影响你一生;有的人热情的为你快乐,却被你悄悄冷落;
技术本身很重要,但如果不能商业化就没有价值。
不要害怕失去,或许,过程很难熬,但是,总有一天会过去。感冒也会随着时间,身体而产生了抗体,慢慢的忘记,成为美好的回忆。
能被感动,说明它提供了你生活中所没有的体验
教会我们生活的,是生活本身。教会我们爱情的,一定也会是爱情本身。所谓,经历即财富
这个世界,通常是只见新人笑,不见旧人哭的。更何况,当初,做新人欢笑时,未必就怜悯过旧人的悲痛欲绝。活该
人生一世,来去都那样匆匆,爱情的离合、存无,那样短暂也为正常。
路边的野花不要采,是因为,作为男人,有责任培育、呵护家花,毕竟,不论家花名贵是否,或者凋零与否,这花,曾经是你自己选择,并且亲手栽下的。
男人呀,如果你想你的亲生儿子不象你,那你娶非处女,有科学依据的,非纯女生的孩子跟她的第一个男人想象
爱一个,并不知晓你爱的人。就像你喜爱一件衣服一样,你只管的喜爱,别求它回敬你的爱。因为它不是活物,它不知晓你爱,它不懂得你爱
站着做人跪着做事
没有起色时,嫌他爬行太久没站立,你就弃他而去。这也就看出来你不是真善之辈
都说社会主义发展是摸着石头过河,但怎么能摸着奶头过河呢?
虚无是上帝给予人最大的惩罚──他让人自己把自己剥夺得精光
对于这些农村的家庭而言,孩子不上学是等着穷,而孩子一上学那就是马上穷
有的人你看了一辈子,却忽视了一辈子;有的人你看了一眼,却影响你一生;有的人热情的为你快乐,却被你悄悄冷落;
技术本身很重要,但如果不能商业化就没有价值。
不要害怕失去,或许,过程很难熬,但是,总有一天会过去。感冒也会随着时间,身体而产生了抗体,慢慢的忘记,成为美好的回忆。
能被感动,说明它提供了你生活中所没有的体验
教会我们生活的,是生活本身。教会我们爱情的,一定也会是爱情本身。所谓,经历即财富
这个世界,通常是只见新人笑,不见旧人哭的。更何况,当初,做新人欢笑时,未必就怜悯过旧人的悲痛欲绝。活该
人生一世,来去都那样匆匆,爱情的离合、存无,那样短暂也为正常。
路边的野花不要采,是因为,作为男人,有责任培育、呵护家花,毕竟,不论家花名贵是否,或者凋零与否,这花,曾经是你自己选择,并且亲手栽下的。
男人呀,如果你想你的亲生儿子不象你,那你娶非处女,有科学依据的,非纯女生的孩子跟她的第一个男人想象
爱一个,并不知晓你爱的人。就像你喜爱一件衣服一样,你只管的喜爱,别求它回敬你的爱。因为它不是活物,它不知晓你爱,它不懂得你爱
站着做人跪着做事
没有起色时,嫌他爬行太久没站立,你就弃他而去。这也就看出来你不是真善之辈
未来的世界:方向比努力重要,能力比知识重要,健康比成绩重要,生活比文凭重要,情商比智商重要!” 阅读全文
删除 core 文件
# find ~ -name core -exec file {} \; -exec rm -i {} \;
查看使用文件的进程
# fuser -u /usr/my_application/foo
搜索字符串
#grep "hello world" `find ./ -name "*" -print -exec file {} \; |grep text | cut -d ':' -f 1`
目录
#alias dir='ls -Lla|grep ^d'
输出 IP 地址
#ifconfig | grep "inet addr" | grep -v "127.0.0.1" | awk '{print $2;}' | awk -F':' '{print $2;}'
按文件长度排序
#ls -l | grep ^- | sort -nr -k 5 | more
#ls -lR | grep ^- | sort -nr -k 5 | more
二进制文件中的可打印字符
# strings name of binary file
一个月的最后一个星期天执行任务:
18 * * * 0 [`date "+%d"` -gt 24] && /path/to/script
修改扩展名:
# for f in *.abc; do mv $f `basename $f .abc`.def ; done
查看硬盘情况:(Solaris)
# iostat -En
整个目录树拷贝:
# cd
# find . -depth -print | cpio -pudm
按长度排序目录下所有文件
# du -a | sort -n -r | more
检查文件内每行是否有相同列数
#awk '{print NF}' test.txt |sort -nu|more
去除空行
#sed -e '/^[ ]*$/d' InputFile >OutputFile
查看进程占用的对应文件 inode 号(Solaris)
#/usr/proc/bin/pfiles
删除指定用户的所有进程
# kill -9 `ps -fu username |awk '{ print $2 }'|grep -v PID`
Bash 操作快捷键:
ctrl-l -- clear screen
ctrl-r -- does a search in the previously given commands so that you don't
have to repeat long command.
ctrl-u -- clears the typing before the hotkey.
ctrl-a -- takes you to the begining of the command you are currently typing.
ctrl-e -- takes you to the end of the command you are currently typing in.
esc-b -- takes you back by one word while typing a command.
ctrl-c -- kills the current command or process.
ctrl-d -- kills the shell.
ctrl-h -- deletes one letter at a time from the command you are typing in.
ctrl-z -- puts the currently running process in background, the process
can be brought back to run state by using fg command.
esc-p -- like ctrl-r lets you search through the previously given commands.
esc-. -- gives the last command you typed.
文件名里的空格替换为下划线
# for i in $1 ; do mv "$i" `echo $i | sed 's/ /_/g'` ; done
查看远程主机时间
# telnet remotehostname 13|grep :
只显示 top 命令的states 行
#while true; do top -d 2 | col -b | grep states; sleep 10; done
加速显示 tar 文件内容
# tar tvfn
让 目录名也能 Spell Check
#shopt -s cdspell
当输错命令时,系统会自动进入类似的目录
查看 Sun 服务器型号
# /usr/platform/`uname -m`/sbin/prtdiag -v | grep `uname -m`
在vi 中一行文字前后添加字符
:/^\(.*\)/s//我要 \1 添加/
查找某包含字符串(Verita)软件包的详细信息 (Solaris)
pkginfo -l `pkginfo | grep -i VERITAS | awk '{print $2}'`
Sun 的一大堆脚本
http://www.sun.com/bigadmin/scripts/index.html
# find ~ -name core -exec file {} \; -exec rm -i {} \;
查看使用文件的进程
# fuser -u /usr/my_application/foo
搜索字符串
#grep "hello world" `find ./ -name "*" -print -exec file {} \; |grep text | cut -d ':' -f 1`
目录
#alias dir='ls -Lla|grep ^d'
输出 IP 地址
#ifconfig | grep "inet addr" | grep -v "127.0.0.1" | awk '{print $2;}' | awk -F':' '{print $2;}'
按文件长度排序
#ls -l | grep ^- | sort -nr -k 5 | more
#ls -lR | grep ^- | sort -nr -k 5 | more
二进制文件中的可打印字符
# strings name of binary file
一个月的最后一个星期天执行任务:
18 * * * 0 [`date "+%d"` -gt 24] && /path/to/script
修改扩展名:
# for f in *.abc; do mv $f `basename $f .abc`.def ; done
查看硬盘情况:(Solaris)
# iostat -En
整个目录树拷贝:
# cd
# find . -depth -print | cpio -pudm
按长度排序目录下所有文件
# du -a | sort -n -r | more
检查文件内每行是否有相同列数
#awk '{print NF}' test.txt |sort -nu|more
去除空行
#sed -e '/^[ ]*$/d' InputFile >OutputFile
查看进程占用的对应文件 inode 号(Solaris)
#/usr/proc/bin/pfiles
删除指定用户的所有进程
# kill -9 `ps -fu username |awk '{ print $2 }'|grep -v PID`
Bash 操作快捷键:
ctrl-l -- clear screen
ctrl-r -- does a search in the previously given commands so that you don't
have to repeat long command.
ctrl-u -- clears the typing before the hotkey.
ctrl-a -- takes you to the begining of the command you are currently typing.
ctrl-e -- takes you to the end of the command you are currently typing in.
esc-b -- takes you back by one word while typing a command.
ctrl-c -- kills the current command or process.
ctrl-d -- kills the shell.
ctrl-h -- deletes one letter at a time from the command you are typing in.
ctrl-z -- puts the currently running process in background, the process
can be brought back to run state by using fg command.
esc-p -- like ctrl-r lets you search through the previously given commands.
esc-. -- gives the last command you typed.
文件名里的空格替换为下划线
# for i in $1 ; do mv "$i" `echo $i | sed 's/ /_/g'` ; done
查看远程主机时间
# telnet remotehostname 13|grep :
只显示 top 命令的states 行
#while true; do top -d 2 | col -b | grep states; sleep 10; done
加速显示 tar 文件内容
# tar tvfn
让 目录名也能 Spell Check
#shopt -s cdspell
当输错命令时,系统会自动进入类似的目录
查看 Sun 服务器型号
# /usr/platform/`uname -m`/sbin/prtdiag -v | grep `uname -m`
在vi 中一行文字前后添加字符
:/^\(.*\)/s//我要 \1 添加/
查找某包含字符串(Verita)软件包的详细信息 (Solaris)
pkginfo -l `pkginfo | grep -i VERITAS | awk '{print $2}'`
Sun 的一大堆脚本
http://www.sun.com/bigadmin/scripts/index.html
linux date得到上一小时的时间:
date -d "-1 hour" "+%Y-%m-%d-%H"
直接输出时间和日期:
监控到XXXX。2016-01-28 14:55:34
七天前的日期:
[root@i popularity]# cat a.sh
echo `date +%y-%m-%d`
`:是ESC上面那个点,不是单纯的点。
1. 利用时区,比较笨的办法,不过也可以用.注意改回时区哦.
$#看当前时区
$echo $TZ
CST-8
$#显示当前时间
$date
Mon Apr 2 15:48:36 CST 2002
$#改变当前时区,
TZ=CST+16;export TZ
$#显示当前时间(中间未改变系统时间,但date命令的显示已为昨天)
Mon Apr 1 15:48:33 CST 2002
2.
假如今天是2005-05-17
取2004-09-25
#date -d"-1 year +4 month +8 day" +%Y-%m-%d
取2008-02-12
#date -d"+3 year -3 month -5 day" +%Y-%m-%d
有哥们回复加上:
date +%F --date='1 days ago'
name=$(date -u +'%Y%m%d')
echo $name;
[/usr/local/361sport_2010]# sh date.sh
select FQQ from Tbl_User order by FScoreCount into outfile '/tmp/361sport_2010_order_out_all_20100823.log
date -u:直接输出时间
20101203
date -d://时间天数加减
昨天:
date -d"-1 day" +%Y%m%d
(1)年月天数相减:
date -d"+3 year -3 month -5 day" +%Y-%m-%d
2013-08-29
(2)年月日格式2:
date -d"+3 year -3 month -5 day" +%Y%m%d
20130829
date -d "-1 hour" "+%Y-%m-%d-%H"
直接输出时间和日期:
监控到XXXX。2016-01-28 14:55:34
七天前的日期:
[root@i popularity]# cat a.sh
echo `date +%y-%m-%d`
`:是ESC上面那个点,不是单纯的点。
1. 利用时区,比较笨的办法,不过也可以用.注意改回时区哦.
$#看当前时区
$echo $TZ
CST-8
$#显示当前时间
$date
Mon Apr 2 15:48:36 CST 2002
$#改变当前时区,
TZ=CST+16;export TZ
$#显示当前时间(中间未改变系统时间,但date命令的显示已为昨天)
Mon Apr 1 15:48:33 CST 2002
2.
假如今天是2005-05-17
取2004-09-25
#date -d"-1 year +4 month +8 day" +%Y-%m-%d
取2008-02-12
#date -d"+3 year -3 month -5 day" +%Y-%m-%d
有哥们回复加上:
date +%F --date='1 days ago'
[root@i model]# date +%F --date='1 days ago'
2009-05-06
2009-05-06
name=$(date -u +'%Y%m%d')
echo $name;
#!/bin/bash
sql="select FQQ from Tbl_User order by FScoreCount into outfile '/tmp/361sport_2010_order_out_all_$(date +%Y%m%d).log";
echo $sql;
sql="select FQQ from Tbl_User order by FScoreCount into outfile '/tmp/361sport_2010_order_out_all_$(date +%Y%m%d).log";
echo $sql;
[/usr/local/361sport_2010]# sh date.sh
select FQQ from Tbl_User order by FScoreCount into outfile '/tmp/361sport_2010_order_out_all_20100823.log
date -u:直接输出时间
date -u +%Y%m%d
20101203
date -d://时间天数加减
昨天:
date -d"-1 day" +%Y%m%d
(1)年月天数相减:
date -d"+3 year -3 month -5 day" +%Y-%m-%d
2013-08-29
(2)年月日格式2:
date -d"+3 year -3 month -5 day" +%Y%m%d
20130829
什么是胆识?胆识=胆量+见识。If 胆量>见识,then 会因为轻举妄动而导致失败;If 胆量<见识,then 会因为保守固化而贻误战机。只有胆量又大,见识又多时,我们才能冷静而机智地分析问题,并能用平和的心态、宽广的视野和全新的思维方式来解决问题,我们有自已的主见,不会人云亦云,不会手足无措,而是敢于挑战自已,敢于创新,敢于突破。
什么是远离:一是远离客户,二是远离员工。什么是远离?远离就是不再仔细倾听他们的意见。
什么是远离:一是远离客户,二是远离员工。什么是远离?远离就是不再仔细倾听他们的意见。
回忆那个光影交错的武侠江湖,醉生梦死的凄美时光...
忧伤,孤独,爱情,像迷离眩目的花,漫天飞舞在滚滚黄沙中...
★.任何人都可以变得狠毒,只要你尝试过什么叫嫉妒.
★.你知道喝水和喝酒的区别吗?酒越喝越暖,水会越喝越寒.阅读全文
忧伤,孤独,爱情,像迷离眩目的花,漫天飞舞在滚滚黄沙中...
★.任何人都可以变得狠毒,只要你尝试过什么叫嫉妒.
★.你知道喝水和喝酒的区别吗?酒越喝越暖,水会越喝越寒.阅读全文
firefox和ie在修改了本机的hosts文件后,必须重起一下ie才起作用,今天看到有人讨论这个问题,问有没有办法可以用命令行清空dns的cache,直接使修改过的hosts文件生效,而不需要重起ff或者ie。
方法很简单
ipconfig/displaydns Display the contents of the DNS Resolver Cache.
显示dns cache的内容,包括hosts文件里的信息也会显示出来。
ipconfig这个命令经常用,常用的有:
/all Display full configuration information.
/release Release the IP address for the specified adapter.
/renew Renew the IP address for the specified adapter.
但是这个关于dns的功能很少用。还有
/registerdns Refreshes all DHCP leases and re-registers DNS names
/showclassid Displays all the dhcp class IDs allowed for adapter.
/setclassid Modifies the dhcp class id
方法很简单
ipconfig /flushdns
相应的还有ipconfig/displaydns Display the contents of the DNS Resolver Cache.
显示dns cache的内容,包括hosts文件里的信息也会显示出来。
ipconfig这个命令经常用,常用的有:
/all Display full configuration information.
/release Release the IP address for the specified adapter.
/renew Renew the IP address for the specified adapter.
但是这个关于dns的功能很少用。还有
/registerdns Refreshes all DHCP leases and re-registers DNS names
/showclassid Displays all the dhcp class IDs allowed for adapter.
/setclassid Modifies the dhcp class id
在新的centos6.2里是这样来安这个setup的。
在command terminal输入:
当我登陆到 CentOS 5.3 中,尝试使用netconfig 是不能使用的,并不奇怪。。。
以前版本:
rpm -ivh netconfig-0.8.24-1.2.2.1.i386.rpm
在CentOs5.3没有找到。
也可以直接:
vi /etc/sysconfig/network-script/ifcfg-eth0
一 ,修改:
/etc/sysconfig/network-scripts/ifcfg-eth0
二修改网关
三修改DNS
四重新启动网络配置
改主机名
vi /etc/sysconfig/network
但是我是一个懒人的嘛: 其次就使用 setup 来配置,觉得有点惊奇,因为5.1版本可以使用的命令,现在不能
rpm -ql setup-2.5.58-4.el5.noarch.rpm
可能是setup没有添加到环境变量的原因,连setup都没有用上,太他妈的倒霉了饿:
最后,
使用了。只好使用 system-config-network!
注意:netconfig是RHEL4 CentOS4里的命令了, RHEL5和CentOS5用setup了,界面跟以前几乎一样。
# rpm -q -a
或者:
rpm -qa |grep man
看有没有man、netconfig的包文件?
没有就要安装
-q name :查询
-qa查询所有已安装的RPM
-qi name 查询这个软件详细信息
-ql 显示列表
-qf path :查询一个文件属于哪个包
-qp 包名 :查文件是什么
-qpl 包名 :针对一个没装过的包
没有的话安装相应的RPM包吧?
你如果用的是:as5不完全安装时没有这个命令的
直接用setup!
选择:network configuration 即可配置!
其实你也可以修改:
进行配置!
Centos6,Rpm安装,不知道是不是这个,但安了才能使用setup:
rpm -ihv ./Packages/setuptool-1.19.9-3.el6.i686.rpm
rpm -ihv ./Packages/usermode-1.102-3.el6.i686.rpm
在command terminal输入:
#netconfig
[code][root@vm02 ~]# netconfig
netconfig: Command not found.
[/code]检查你是root?你装了netconfig的rpm包了吗?find / -name netconfig -print找一下有没有!netconfig: Command not found.
当我登陆到 CentOS 5.3 中,尝试使用netconfig 是不能使用的,并不奇怪。。。
以前版本:
rpm -ivh netconfig-0.8.24-1.2.2.1.i386.rpm
在CentOs5.3没有找到。
也可以直接:
vi /etc/sysconfig/network-script/ifcfg-eth0
一 ,修改:
/etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
ONBOOT=yes
BOOTPROTO=static dhcp
IPADDR=192.168.1.101
NETMASK=255.255.255.0
GATEWAY=192.168.1.254
ONBOOT=yes
BOOTPROTO=static dhcp
IPADDR=192.168.1.101
NETMASK=255.255.255.0
GATEWAY=192.168.1.254
二修改网关
vi /etc/sysconfig/networkNETWORKING=yes
HOSTNAME=Aaron
GATEWAY=192.168.1.254
HOSTNAME=Aaron
GATEWAY=192.168.1.254
三修改DNS
vi /etc/resolv.confnameserver 202.96.128.68
nameserver 219.136.241.206
nameserver 219.136.241.206
四重新启动网络配置
/etc/init.d/network restart
service network stop
service network start
service network stop
service network start
改主机名
vi /etc/sysconfig/network
但是我是一个懒人的嘛: 其次就使用 setup 来配置,觉得有点惊奇,因为5.1版本可以使用的命令,现在不能
setup-2.5.58-4.el5.noarch.rpm
rpm -ihv setup-2.5.58-4.el5.noarch.rpm
rpm -ihv setup-2.5.58-4.el5.noarch.rpm
rpm -ql setup-2.5.58-4.el5.noarch.rpm
可能是setup没有添加到环境变量的原因,连setup都没有用上,太他妈的倒霉了饿:
最后,
使用了。只好使用 system-config-network!
注意:netconfig是RHEL4 CentOS4里的命令了, RHEL5和CentOS5用setup了,界面跟以前几乎一样。
# rpm -q -a
或者:
rpm -qa |grep man
rpm -qa |grep netconfig
看有没有man、netconfig的包文件?
没有就要安装
-q name :查询
-qa查询所有已安装的RPM
-qi name 查询这个软件详细信息
-ql 显示列表
-qf path :查询一个文件属于哪个包
-qp 包名 :查文件是什么
-qpl 包名 :针对一个没装过的包
没有的话安装相应的RPM包吧?
你如果用的是:as5不完全安装时没有这个命令的
直接用setup!
选择:network configuration 即可配置!
其实你也可以修改:
/etc/sysconfig/network-scripts/ifcfg-eth0
进行配置!
Centos6,Rpm安装,不知道是不是这个,但安了才能使用setup:
rpm -ihv ./Packages/setuptool-1.19.9-3.el6.i686.rpm
rpm -ihv ./Packages/usermode-1.102-3.el6.i686.rpm
我们需要对这个数组先按照score【分数排序:由高到低】,然后再由name[姓名低到高排序]:
特别注意:array_multisort对姓名排序时候要utf8【假如是UTF8】转为gbk,否则排序出现错误,切忌切忌!!!
1.排序代码:[特别注意:我在排序分数的时候有个千分位输出,最后排序发现它会当成整形去处理,逗号{千分位分隔符}会截断],所以,最好是先排好【对score排好--》在通过number_format来千分位输出,见下代码:】
由于调用用户姓名接口是utf8输出,我们这儿的php文件是gbk编码【由于大部规定:除了html模板,接口返回编码和数据存储为utf8外其余都是gbk编码,因此:我这个modle层的编码也是gbk的】,为此,必须转为gbk来进行中文名的二次排序【首先是按照分数来排序,这个数组在后面给出】,
注意:转为GBK编码片段: iconv("UTF-8","GBK",$v);
排序代码:
Array
(
[0] => Array
(
[name] => 盛大师
[uid] => 1159375663
[score] => 88,897,776
[potourl] => http://p8.sinaimg.cn/1159375663/50/1236592606
[imgsrc] => Array
(
[0] => renyuan_level_1.gif
[1] => renyuan_level_1.gif
[2] => renyuan_level_1.gif
[3] => renyuan_level_1.gif
[4] => renyuan_level_1.gif
[5] => renyuan_level_1.gif
)
)
[1] => Array
(
[name] => 你好
[uid] => 1377417885
[score] => 728,888
[potourl] => http://p6.sinaimg.cn/1377417885/50/1234321817
[imgsrc] => Array
(
[0] => renyuan_level_1.gif
[1] => renyuan_level_1.gif
[2] => renyuan_level_1.gif
[3] => renyuan_level_1.gif
)
)
[2] => Array
(
[name] => 笨蛋
[uid] => 1584778420
[score] => 77,909
[potourl] => http://p5.sinaimg.cn/1584778420/50/
[imgsrc] => Array
(
[0] => renyuan_level_2.gif
[1] => renyuan_level_2.gif
[2] => renyuan_level_2.gif
[3] => renyuan_level_2.gif
[4] => renyuan_level_2.gif
)
)
[3] => Array
(
[name] => 吥喜欢
[uid] => 1581862283
[score] => 17,776
[potourl] => http://p4.sinaimg.cn/1581862283/50/1239087886
[imgsrc] => Array
(
[0] => renyuan_level_3.gif
[1] => renyuan_level_3.gif
[2] => renyuan_level_3.gif
[3] => renyuan_level_3.gif
[4] => renyuan_level_3.gif
[5] => renyuan_level_3.gif
)
)
[4] => Array
(
[name] => 阿里爸
[uid] => 1582003980
[score] => 17,776
[potourl] => http://p5.sinaimg.cn/1582003980/50/1232551415
[imgsrc] => Array
(
[0] => renyuan_level_3.gif
[1] => renyuan_level_3.gif
[2] => renyuan_level_3.gif
[3] => renyuan_level_3.gif
[4] => renyuan_level_3.gif
[5] => renyuan_level_3.gif
)
)
[5] => Array
(
[name] => 科比
[uid] => 1582157323
[score] => 17,776
[potourl] => http://p4.sinaimg.cn/1582157323/50/1232615329
[imgsrc] => Array
(
[0] => renyuan_level_3.gif
[1] => renyuan_level_3.gif
[2] => renyuan_level_3.gif
[3] => renyuan_level_3.gif
[4] => renyuan_level_3.gif
[5] => renyuan_level_3.gif
)
)
[6] => Array
(
[name] => 琳琳琳
[uid] => 1281167662
[score] => 17,776
[potourl] => http://p7.sinaimg.cn/1281167662/50/1239361854
[imgsrc] => Array
(
[0] => renyuan_level_3.gif
[1] => renyuan_level_3.gif
[2] => renyuan_level_3.gif
[3] => renyuan_level_3.gif
[4] => renyuan_level_3.gif
[5] => renyuan_level_3.gif
)
)
[7] => Array
(
[name] => 克里斯大王
[uid] => 1141457724
[score] => 8,988
[potourl] => http://p5.sinaimg.cn/1141457724/50/1232521326
[imgsrc] => Array
(
[0] => renyuan_level_3.gif
[1] => renyuan_level_3.gif
[2] => renyuan_level_3.gif
[3] => renyuan_level_3.gif
[4] => renyuan_level_3.gif
)
)
[8] => Array
(
[name] => 苗艳宏
[uid] => 1581837512
[score] => 8,988
[potourl] => http://p1.sinaimg.cn/1581837512/50/1236940821
[imgsrc] => Array
(
[0] => renyuan_level_3.gif
[1] => renyuan_level_3.gif
[2] => renyuan_level_3.gif
[3] => renyuan_level_3.gif
[4] => renyuan_level_3.gif
)
)
[9] => Array
(
[name] => 朱阿里
[uid] => 1180166542
[score] => 8,988
[potourl] => http://p7.sinaimg.cn/1180166542/50/
[imgsrc] => Array
(
[0] => renyuan_level_3.gif
[1] => renyuan_level_3.gif
[2] => renyuan_level_3.gif
[3] => renyuan_level_3.gif
[4] => renyuan_level_3.gif
)
)
)
对二维数组里的某列键值进行排序有点相当于sql语句,array_multisort() 可以用来一次对多个数组进行排序,或者根据某一维或多维对多维数组进行排序。 关联(string)键名保持不变,但数字键名会被重新索引。 :
参考自己http://www.jb51.net/article/25882.htm
输出如下所示:
---------- 调试PHP ----------
Array
(
[0] => Array
(
[id] => 6
[value] => 6-1
[parent] => 3
)
[1] => Array
(
[id] => 5
[value] => 5-1
[parent] => 2
)
[2] => Array
(
[id] => 4
[value] => 4-1
[parent] => 2
)
[3] => Array
(
[id] => 3
[value] => 3-1
[parent] => 1
)
[4] => Array
(
[id] => 2
[value] => 2-1
[parent] => 1
)
[5] => Array
(
[id] => 1
[value] => 1-1
[parent] => 1
)
)
输出完成 (耗时 0 秒) - 正常终止
特别注意:array_multisort对姓名排序时候要utf8【假如是UTF8】转为gbk,否则排序出现错误,切忌切忌!!!
1.排序代码:[特别注意:我在排序分数的时候有个千分位输出,最后排序发现它会当成整形去处理,逗号{千分位分隔符}会截断],所以,最好是先排好【对score排好--》在通过number_format来千分位输出,见下代码:】
由于调用用户姓名接口是utf8输出,我们这儿的php文件是gbk编码【由于大部规定:除了html模板,接口返回编码和数据存储为utf8外其余都是gbk编码,因此:我这个modle层的编码也是gbk的】,为此,必须转为gbk来进行中文名的二次排序【首先是按照分数来排序,这个数组在后面给出】,
注意:转为GBK编码片段: iconv("UTF-8","GBK",$v);
foreach($resultname as $k =>$v)
{
$arraydisplay[$i][name] = iconv("UTF-8","GBK",$v);
$arraydisplay[$i][uid] = $k;
$arraydisplay[$i][score] = $json2array[$k];
$arraydisplay[$i][potourl] = $resulticon[$k];
foreach ($level_type as $kka =>$vvc)
{
if(($json2array[$k]<=$vvc[1])&&($json2array[$k]>=$vvc[0]))
{
$imgurl = $LeavelImg[$kka][0];//取得图片地址
$loopimg = $LeavelImg[$kka][1];
for($jj=0;$jj<$loopimg;$jj++)
{
$imgnum[] = $imgurl;
}
break;
}
}
$arraydisplay[$i][imgsrc] = $imgnum;
unset($imgnum);
$i++;
}
{
$arraydisplay[$i][name] = iconv("UTF-8","GBK",$v);
$arraydisplay[$i][uid] = $k;
$arraydisplay[$i][score] = $json2array[$k];
$arraydisplay[$i][potourl] = $resulticon[$k];
foreach ($level_type as $kka =>$vvc)
{
if(($json2array[$k]<=$vvc[1])&&($json2array[$k]>=$vvc[0]))
{
$imgurl = $LeavelImg[$kka][0];//取得图片地址
$loopimg = $LeavelImg[$kka][1];
for($jj=0;$jj<$loopimg;$jj++)
{
$imgnum[] = $imgurl;
}
break;
}
}
$arraydisplay[$i][imgsrc] = $imgnum;
unset($imgnum);
$i++;
}
排序代码:
$arraydisplay = array_chunk($arraydisplay,10,TRUE);//截取前10个人的数据给smarty $data = $arraydisplay[0];
unset($arraydisplay);
unset($arraydisplay);
foreach ($data as $key => $row)
{
$score[$key] = $row['score'];
$name[$key] = $row['name'];
}
array_multisort($score, SORT_DESC, $name, SORT_ASC, $data);
for($iii=0;$iii<10;$iii++)
{
$data[$iii]['name'] = iconv("GBK","UTF-8",$data[$iii]['name']);
$data[$iii]['score'] = number_format($data[$iii]['score']);
}
$result = $data;
}
unset($arraydisplay);
unset($arraydisplay);
foreach ($data as $key => $row)
{
$score[$key] = $row['score'];
$name[$key] = $row['name'];
}
array_multisort($score, SORT_DESC, $name, SORT_ASC, $data);
for($iii=0;$iii<10;$iii++)
{
$data[$iii]['name'] = iconv("GBK","UTF-8",$data[$iii]['name']);
$data[$iii]['score'] = number_format($data[$iii]['score']);
}
$result = $data;
}
Array
(
[0] => Array
(
[name] => 盛大师
[uid] => 1159375663
[score] => 88,897,776
[potourl] => http://p8.sinaimg.cn/1159375663/50/1236592606
[imgsrc] => Array
(
[0] => renyuan_level_1.gif
[1] => renyuan_level_1.gif
[2] => renyuan_level_1.gif
[3] => renyuan_level_1.gif
[4] => renyuan_level_1.gif
[5] => renyuan_level_1.gif
)
)
[1] => Array
(
[name] => 你好
[uid] => 1377417885
[score] => 728,888
[potourl] => http://p6.sinaimg.cn/1377417885/50/1234321817
[imgsrc] => Array
(
[0] => renyuan_level_1.gif
[1] => renyuan_level_1.gif
[2] => renyuan_level_1.gif
[3] => renyuan_level_1.gif
)
)
[2] => Array
(
[name] => 笨蛋
[uid] => 1584778420
[score] => 77,909
[potourl] => http://p5.sinaimg.cn/1584778420/50/
[imgsrc] => Array
(
[0] => renyuan_level_2.gif
[1] => renyuan_level_2.gif
[2] => renyuan_level_2.gif
[3] => renyuan_level_2.gif
[4] => renyuan_level_2.gif
)
)
[3] => Array
(
[name] => 吥喜欢
[uid] => 1581862283
[score] => 17,776
[potourl] => http://p4.sinaimg.cn/1581862283/50/1239087886
[imgsrc] => Array
(
[0] => renyuan_level_3.gif
[1] => renyuan_level_3.gif
[2] => renyuan_level_3.gif
[3] => renyuan_level_3.gif
[4] => renyuan_level_3.gif
[5] => renyuan_level_3.gif
)
)
[4] => Array
(
[name] => 阿里爸
[uid] => 1582003980
[score] => 17,776
[potourl] => http://p5.sinaimg.cn/1582003980/50/1232551415
[imgsrc] => Array
(
[0] => renyuan_level_3.gif
[1] => renyuan_level_3.gif
[2] => renyuan_level_3.gif
[3] => renyuan_level_3.gif
[4] => renyuan_level_3.gif
[5] => renyuan_level_3.gif
)
)
[5] => Array
(
[name] => 科比
[uid] => 1582157323
[score] => 17,776
[potourl] => http://p4.sinaimg.cn/1582157323/50/1232615329
[imgsrc] => Array
(
[0] => renyuan_level_3.gif
[1] => renyuan_level_3.gif
[2] => renyuan_level_3.gif
[3] => renyuan_level_3.gif
[4] => renyuan_level_3.gif
[5] => renyuan_level_3.gif
)
)
[6] => Array
(
[name] => 琳琳琳
[uid] => 1281167662
[score] => 17,776
[potourl] => http://p7.sinaimg.cn/1281167662/50/1239361854
[imgsrc] => Array
(
[0] => renyuan_level_3.gif
[1] => renyuan_level_3.gif
[2] => renyuan_level_3.gif
[3] => renyuan_level_3.gif
[4] => renyuan_level_3.gif
[5] => renyuan_level_3.gif
)
)
[7] => Array
(
[name] => 克里斯大王
[uid] => 1141457724
[score] => 8,988
[potourl] => http://p5.sinaimg.cn/1141457724/50/1232521326
[imgsrc] => Array
(
[0] => renyuan_level_3.gif
[1] => renyuan_level_3.gif
[2] => renyuan_level_3.gif
[3] => renyuan_level_3.gif
[4] => renyuan_level_3.gif
)
)
[8] => Array
(
[name] => 苗艳宏
[uid] => 1581837512
[score] => 8,988
[potourl] => http://p1.sinaimg.cn/1581837512/50/1236940821
[imgsrc] => Array
(
[0] => renyuan_level_3.gif
[1] => renyuan_level_3.gif
[2] => renyuan_level_3.gif
[3] => renyuan_level_3.gif
[4] => renyuan_level_3.gif
)
)
[9] => Array
(
[name] => 朱阿里
[uid] => 1180166542
[score] => 8,988
[potourl] => http://p7.sinaimg.cn/1180166542/50/
[imgsrc] => Array
(
[0] => renyuan_level_3.gif
[1] => renyuan_level_3.gif
[2] => renyuan_level_3.gif
[3] => renyuan_level_3.gif
[4] => renyuan_level_3.gif
)
)
)
对二维数组里的某列键值进行排序有点相当于sql语句,array_multisort() 可以用来一次对多个数组进行排序,或者根据某一维或多维对多维数组进行排序。 关联(string)键名保持不变,但数字键名会被重新索引。 :
参考自己http://www.jb51.net/article/25882.htm
输出如下所示:
---------- 调试PHP ----------
Array
(
[0] => Array
(
[id] => 6
[value] => 6-1
[parent] => 3
)
[1] => Array
(
[id] => 5
[value] => 5-1
[parent] => 2
)
[2] => Array
(
[id] => 4
[value] => 4-1
[parent] => 2
)
[3] => Array
(
[id] => 3
[value] => 3-1
[parent] => 1
)
[4] => Array
(
[id] => 2
[value] => 2-1
[parent] => 1
)
[5] => Array
(
[id] => 1
[value] => 1-1
[parent] => 1
)
)
输出完成 (耗时 0 秒) - 正常终止
//程序中
//函数地定义
//模板中使用
实例:
HTML调用:
参看:http://movoin.com/index.php/archives/182
http://www.phpx.com/happy/thread-123410-1-1.html
$smarty->register_function('asc','asc_num');
//函数地定义
function asc_num($params){
extract($params);
echo chr($num+64);
}
extract($params);
echo chr($num+64);
}
//模板中使用
<{asc num=$smarty.section.loop2.iteration}>
实例:
function insert_left($params, &$smarty) {
global $FOURAPP;
$o_app = new AppProx;
$bRet = $o_app->getUserList(&$objarr, $params['cuseruid']);
if($bRet) {
if(is_array($objarr) && count($objarr)>0) {
$userapplist = array_diff_key($objarr, $FOURAPP);
} else {
$userapplist = array();
}
$smarty->assign('cuseruid', $params['cuseruid']);
$smarty->assign('userappnum', count($userapplist));
$smarty->assign('userapplist', &$userapplist);
$smarty->assign('fourapp', &$FOURAPP);
}
$html = &$smarty->fetch('part/left.html');
return $html;
}
function insert_top($params,&$smarty){
$smarty->assign('cuseruid',$params['cuseruid']);
return $smarty->fetch('part/top.html');
}
global $FOURAPP;
$o_app = new AppProx;
$bRet = $o_app->getUserList(&$objarr, $params['cuseruid']);
if($bRet) {
if(is_array($objarr) && count($objarr)>0) {
$userapplist = array_diff_key($objarr, $FOURAPP);
} else {
$userapplist = array();
}
$smarty->assign('cuseruid', $params['cuseruid']);
$smarty->assign('userappnum', count($userapplist));
$smarty->assign('userapplist', &$userapplist);
$smarty->assign('fourapp', &$FOURAPP);
}
$html = &$smarty->fetch('part/left.html');
return $html;
}
function insert_top($params,&$smarty){
$smarty->assign('cuseruid',$params['cuseruid']);
return $smarty->fetch('part/top.html');
}
HTML调用:
<div class="SG_wrapall">
{insert name="top" cuseruid=$uidowner}
</div>
<div class="SG_wrap950 pybg">
<div class="SG_colW13 SG_colFirst">
{insert name="left" cuseruid=$uidowner}
</div>
{insert name="top" cuseruid=$uidowner}
</div>
<div class="SG_wrap950 pybg">
<div class="SG_colW13 SG_colFirst">
{insert name="left" cuseruid=$uidowner}
</div>
参看:http://movoin.com/index.php/archives/182
http://www.phpx.com/happy/thread-123410-1-1.html
{cycle} 用于在值集合中轮换。便于实现下述情况,在一个表格中交替输出两种或多种颜色,在值数组中循环。
Example 8-5. {cycle}
{section name=rows loop=$data}<tr bgcolor="{cycle values="#eeeeee,#d0d0d0"}"> <td>{$data[rows]}</td></tr>{/section}
The above template would output:
<tr bgcolor="#eeeeee"> <td>1</td></tr><tr bgcolor="#d0d0d0"> <td>2</td></tr><tr bgcolor="#eeeeee"> <td>3</td></tr>
自己测试:
PHP端:
Html输出端:
浏览器展现:
Example 8-5. {cycle}
{section name=rows loop=$data}<tr bgcolor="{cycle values="#eeeeee,#d0d0d0"}"> <td>{$data[rows]}</td></tr>{/section}
The above template would output:
<tr bgcolor="#eeeeee"> <td>1</td></tr><tr bgcolor="#d0d0d0"> <td>2</td></tr><tr bgcolor="#eeeeee"> <td>3</td></tr>
自己测试:
PHP端:
Html输出端:
浏览器展现:
把一个数组按照一定长度截取到另外一个数组中:
$arraydisplay = array_chunk($arraydisplay,10,TRUE);//截取前10个人的数据给smarty
$uids = array();//强制$uids由string改为array()类型
$uids = array_keys($json2array);//把数组的键放到一个数组中。当然可以通过foreach实现,但没有必要!
array_slice -- 从数组中取出一段.
arsort($json2array);
-- 对数组进行逆向排序并保持索引关系
本例输出如下:
$arraydisplay = array_chunk($arraydisplay,10,TRUE);//截取前10个人的数据给smarty
$uids = array();//强制$uids由string改为array()类型
$uids = array_keys($json2array);//把数组的键放到一个数组中。当然可以通过foreach实现,但没有必要!
array_slice -- 从数组中取出一段.
arsort($json2array);
-- 对数组进行逆向排序并保持索引关系
<?php
$fruits = array ("d"=>"lemon", "a"=>"orange", "b"=>"banana", "c"=>"apple");
arsort ($fruits);
reset ($fruits);
while (list ($key, $val) = each ($fruits)) {
echo "$key = $val\n";
}
?>
$fruits = array ("d"=>"lemon", "a"=>"orange", "b"=>"banana", "c"=>"apple");
arsort ($fruits);
reset ($fruits);
while (list ($key, $val) = each ($fruits)) {
echo "$key = $val\n";
}
?>
本例输出如下:
a = orange
d = lemon
b = banana
c = apple
d = lemon
b = banana
c = apple
开发中偶尔会遇到需要跳转页面后到达页面的最上方,如何处理呢?锚点!
方法:在各个页面里面下面就立马加入:
那在页面内呢?
在点击这儿后跳到下描点位置,这儿代码
锚点位置代码:
EOF!
方法:在各个页面里面下面就立马加入:
<a id="top1" name="top1"></a>
<div class="PY_page">
{if $page.totalpage > 1}
<ul class="PY_pages">
{if $page.pagenum > 1}
<li class="PY_pgprev"><a href="{$page.previouspage}#top1" class="Ap_tf"><上一页</a> </li>
{/if}
{foreach from=$pagelistarray item=pagelist}
{if $pagelist.num == $page.pagenum}
<li class="PY_pgon">{$pagelist.num}</li>
{else}
<li><a href='{$pagelist.url}#top1'>{$pagelist.num}</a></li>
{/if}
{/foreach}
{if $page.pagenum < $page.totalpage}
<li class="PY_pgnext"><a href="{$page.nextpage}#top1" class="Ap_tf">下一页></a></li>
{/if}
</ul>
{/if}
</div>
{if $page.totalpage > 1}
<ul class="PY_pages">
{if $page.pagenum > 1}
<li class="PY_pgprev"><a href="{$page.previouspage}#top1" class="Ap_tf"><上一页</a> </li>
{/if}
{foreach from=$pagelistarray item=pagelist}
{if $pagelist.num == $page.pagenum}
<li class="PY_pgon">{$pagelist.num}</li>
{else}
<li><a href='{$pagelist.url}#top1'>{$pagelist.num}</a></li>
{/if}
{/foreach}
{if $page.pagenum < $page.totalpage}
<li class="PY_pgnext"><a href="{$page.nextpage}#top1" class="Ap_tf">下一页></a></li>
{/if}
</ul>
{/if}
</div>
那在页面内呢?
在点击这儿后跳到下描点位置,这儿代码
:<a href="#top1">如何获得积分</a>
锚点位置代码:
<a id="top1" name="top1">如何获得积分</a>
EOF!