曲径通幽论坛

标题: count() -- 获取数组中元素个数 [打印本页]

作者: beyes    时间: 2011-8-31 18:00
标题: count() -- 获取数组中元素个数
count() 函数一般用来获取数组元素个数。

示例代码(和 explode() 函数配合取得文件名后缀):

[PHP] 纯文本查看 复制代码
<?php
        $filename = "123.dadf.2323.sdad.txt";

        $savef = explode(".", $filename);

        $maxn = count($savef);

        echo $savef[$maxn-1];
?>

运行输出:
txt





欢迎光临 曲径通幽论坛 (http://www.groad.net/bbs/) Powered by Discuz! X3.2