search
Homephp教程PHP源码php最简单获取数组最后无素值

<script>ec(2);</script>


//php教程最简单获取数组最后无素值

 代码如下 复制代码
//方法一
$url ='www.111cn.net.cc';
$tmpUrl = explode('.',$url);

//输出temurl看看
print_r($tmpUrl);
/*
结果:

 代码如下 复制代码
Array
(
    [0] => www
    [1] => 111cn
    [2] => net
    [3] => cc
)


*/

//我们来看获取方法一

 代码如下 复制代码

echo end($tmpUrl); //cc

//方法二数组长度
$count = count($tmpUrl);
echo $tmpUrl[$count-1];//cc

/*
总结一下:
方法一用了php内部函数end,这个方便快捷,
方法二用了count统计数组长度再减一,得出相对应的值。
本站原创文章www.111cn.net
*/

?>

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.