Possible Duplicate:
PHP get index of last inserted item in array
我有阵列或多变的长度,希望能迅速而容易地了解最后一个项目在阵列中的价值(实际上不将其从阵列中删除)。 我怎么能够把最后的项目列入议程,而实际上却不将其从阵列中删除?
Possible Duplicate:
PHP get index of last inserted item in array
我有阵列或多变的长度,希望能迅速而容易地了解最后一个项目在阵列中的价值(实际上不将其从阵列中删除)。 我怎么能够把最后的项目列入议程,而实际上却不将其从阵列中删除?
Try end
<?php
$fruits = array( apple , banana , cranberry );
echo end($fruits); // cranberry
?>
For numeric (non-associative) zero-based array you can use this:
$arr = array( one , two , three , four , five );
print $arr[count($arr)-1]; // five
Use array end So if I have an array:
$array_example = array( one , two , three );
我要谈最后一个项目,我可以这样做:
echo end($array_example);
这将反映阵列的最后部分,但不会影响阵列。
在这样做之后,如果你想要重新确定阵列中第一个项目的内部阵列点(以便你能够继续正常工作),那么就重新确定阵列点:
reset($array_example);
最后一期=1美元
this is an alternative to using end, so that you don t have the consequence of having the array s internal pointer moved to the end of the array end - php.net
I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...
<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...
I found this script online that creates a thumbnail out of a image but the thumbnail image is created with poor quality how can I improve the quality of the image. And is there a better way to create ...
如何确认来自正确来源的数字。
Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...
I wonder there is a way to post a message to a facebook business page with cURL? thanks
I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...
How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...