[原]阿拉伯数字金额转中文大写函数(2 位领导批示)

最近正好用到.就自己写了个.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
function chinese_money($money)
{
    $str = array('零','壹','贰','叁','肆','伍','陆','柒','捌','玖');
    $unit = array('零','分','角','元','拾','佰','仟','万','拾','佰','仟','亿','拾','佰','仟');
    $money = str_replace(",","",$money);
    $money = number_format($money,2);
    $money = str_replace(".","",$money);
    $money = str_replace(",","",$money);
    $f = $money;
 
    $money = abs($money);
    if($f != $money) $m = '负';
    $len = strlen($money);
    for ($i=1; $i<=$len; $i++)
    {
        $num = substr($money,$i-1,1);
        $j = strlen($money)+1-$i;
        $m .= $num . $unit[$j];
    }
    foreach($str as $key=>$val)
    {
        $m = str_replace($key,$val,$m);
    }
    return $m;
}
 
$money = 9123123.12;
echo $money . "\n";
echo chinese_money($money);

代码片断(2)(2 位领导批示)

求出100以内的奇数之和与偶数之和

1
2
3
4
5
6
7
8
9
10
11
12
#include "stdio.h"
#include "math.h"
main()
{
  int i,odd,even;
  for(i=1,odd=0,even=0;i<=100;i=i+2)
  {
    odd += i;
    even += i+1;
  }
  printf("%d %d",odd,even);
}
Tags : , ,

代码片断(1)(4 位领导批示)

求两个数的最大公约数与最小公倍数

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include "stdio.h"
#include "math.h"
main()
{
  int m,n,m1,n1,a;
  scanf("%d,%d",&m,&n);
  m1=m;n1=n;
  while(m1%n1)
  {
    a=m1%n1;
    m1=n1;
    n1=a;
  }
  printf("%d, %d",n1, m*n/n1);
}

为了我们的地球请关灯一小时(2 位领导批示)

为了我们的地球,请关灯一小时

时间:2009年3月28日晚8:30-9:30

地点:就在你的家里,就在整个地球!

o72694

[备忘]一个树形类(修正了子节点ID小于父节点ID时的BUG)(1 位领导批示)

这个树形类还是相当好用..
不过今天在使用时数据中出现了子节点id(71)小于父节点id(104).导致部分子节点没被存储入数组
修改了一下..应该没有问题了..

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
<?php
class Tree
{
    var $data = array();
    var $child = array(-1=>array());
    var $layer = array(-1=>-1);
    var $parent = array();
    var $num = array();
 
    function setNode($id, $parent, $value,$num=0)
    {
        $parent = $parent ? $parent : 0;
 
        $this->data[$id]		= $value;
        $this->num[$id]      = $num;
        if (!isset($this->child[$id])) $this->child[$id] = array();
        $this->child[$parent][] = $id;
        $this->parent[$id]		= $parent;
 
        if (!isset($this->layer[$parent]) && $parent == 0)
        {
           $this->layer[$id] = 0;
        }
        else
        {
            $this->layer[$id] = $this->layer[$parent] + 1;
        }
    }
 
 
    function getList(&$tree, $root= 0)
    {
        foreach ($this->child[$root] as $key=>$id)
        {
            $tree[] = $id;
            if($this->child[$id]) $this->getList($tree, $id);
        }
    }
 
    function getValue($id)
    {
		if($this->layer[$id]==0)
		{
			return $this->data[$id];
		}
		else
		{
			return $leftmar.$this->data[$id];
		}
    }
 
    function getNum($id)
    {
		return $this->num[$id];
    }
 
    function getbitValue($id)
    {
		return $this->data[$id];
    }
 
    function getLayer($id, $space = false)
    {
        return $space ? str_repeat($space, $this->layer[$id]) : $this->layer[$id];
    }
 
    function getParent($id)
    {
        return $this->parent[$id];
    }
 
    function getParents($id)
    {
        while ($this->parent[$id] != -1)
        {
            $id = $parent[$this->layer[$id]] = $this->parent[$id];
        }
 
        ksort($parent);
        reset($parent);
 
        return $parent;
    }
 
    function getChild($id)
    {
        return $this->child[$id];
    }
 
    function getChilds($id = 0)
    {
        $child = array($id);
        $this->getList($child, $id);
 
        return $child;
    }
 
    function printData()
    {
        return $this->layer;
    }
}
?>
Tags : , ,

[原]WordPress 评论表情插件 silver smilies v0.1 发布(10 位领导批示)

抽空将原先直接在wp上修改的评论表情做成了插件.
第一次写WordPress插件. WP的hook还是蛮好用的嘛..活活…

下载地址 : www.zdyi.com/wp-content/uploads/2009/03/silver_smilies.rar

全文阅读 »

MSN9.0 去除底部广告(10 位领导批示)

将 msgsres.dll 下载后复制到MSN安装目录.选择覆盖便可 (原msgsres.dll最好进行备份)

msgsres.dll 下载 (Size:11,410,760 bit)

Tags : ,

[备忘]Portable PHP password hashing framework(0 位领导批示)

WordPress 采用的密码加密算法..记录备忘

主要有两个方法:
1.HashPassword 加密密码
2.CheckPassword 进行密码验证

全文阅读 »

Tags : , ,

[备忘]用户提交表单时使用JavaScript进行md5加密(2 位领导批示)

原来POST方法提交的数据是那么容易被监听 -_!!
用js进行第一次加密.提交表单后再进行二次加密.看它还能不能被监听..

全文阅读 »

Ajax中Request缓存的解决方法(1 位领导批示)

今天写到的一个应用中用到了Ajax请求数据.
FF下一切正常.IE下却被顽固的页面缓存给难住了..必须要清理掉缓存才能正确重新请求数据

必须想办法解决Ajax在IE下的缓存问题

其实解决的方法很简单..就是创建httpRequest对象时加上这么一句

?View Code JAVASCRIPT
1
xmlHTTP.setRequestHeader("If-Modified-Since","0");

这样缓存问题就轻松解决了..

随机显示的10篇日志

评论最多的10篇日志

浏览最多的10篇日志