计算数组中的数组数(Count # of arrays in an array)

编程入门 行业动态 更新时间:2024-10-23 07:30:58
计算数组中的数组数(Count # of arrays in an array)

我试图找到我给定数组中的数组总数。 我已经尝试过使用count()函数和sizeof()函数,但是当我知道只有5个时我们都说有66666个数组(我认为这是因为它在while循环中)。

$result = mysql_query("SELECT * FROM products"); while($row = mysql_fetch_assoc($result)) { echo count($row); }

I am trying to find the total number of arrays in my given array. I have tried using the count() function and the sizeof() function but both say that there are 66666 arrays when I know there are only 5 (I think this is because it is in a while loop).

$result = mysql_query("SELECT * FROM products"); while($row = mysql_fetch_assoc($result)) { echo count($row); }

最满意答案

我想你正在寻找这个功能

mysql_num_rows - 获取结果中的行数

文档: http : //www.php.net/manual/en/function.mysql-num-rows.php

正如其他人建议的那样,我至少会研究mysqli或者最好是PDO而不仅仅是mysql。

I think you are looking for this funciton

mysql_num_rows — Get number of rows in result

documentation: http://www.php.net/manual/en/function.mysql-num-rows.php

As others suggested I would look into at least the mysqli or preferably PDO instead of just mysql.

更多推荐

本文发布于:2023-08-06 23:39:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1456770.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:数组   组中   Count   arrays   array

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!