Home > Backend Development > PHP Tutorial > PHP简单的循环赋值问题

PHP简单的循环赋值问题

WBOY
Release: 2016-06-06 20:11:54
Original
1845 people have browsed it

<code>    echo  $ss = count($row['key']);  输出是 111111  统计6个1
    echo '<br>';
    echo $num=count($ss);   统计输出只有1个1 </code>
Copy after login
Copy after login

如何实现 把统计输出6个1的值全部赋值到$num里全显示出来?

<code>    for($i=1;$i</code>
Copy after login
Copy after login

这样列不出来,是不是什么地方写错了?

实际例子:

<code>$dosql->Execute("SELECT * FROM #@__infolist WHERE classid=2 AND delstate='' AND checkinfo=true ORDER BY orderid DESC LIMIT 0,100");
{
while($row = $dosql->GetArray())
echo $ss = $row['keywords']; //输出 你好,你好,你好,不好,很好
echo $num= $ss; //输出 很好

   //目标把 $ss 赋值给 $num 循环出来
        for($i=1;$i</code>
Copy after login
Copy after login

回复内容:

<code>    echo  $ss = count($row['key']);  输出是 111111  统计6个1
    echo '<br>';
    echo $num=count($ss);   统计输出只有1个1 </code>
Copy after login
Copy after login

如何实现 把统计输出6个1的值全部赋值到$num里全显示出来?

<code>    for($i=1;$i</code>
Copy after login
Copy after login

这样列不出来,是不是什么地方写错了?

实际例子:

<code>$dosql->Execute("SELECT * FROM #@__infolist WHERE classid=2 AND delstate='' AND checkinfo=true ORDER BY orderid DESC LIMIT 0,100");
{
while($row = $dosql->GetArray())
echo $ss = $row['keywords']; //输出 你好,你好,你好,不好,很好
echo $num= $ss; //输出 很好

   //目标把 $ss 赋值给 $num 循环出来
        for($i=1;$i</code>
Copy after login
Copy after login

<code>$dosql->Execute("SELECT * FROM #@__infolist WHERE classid=2 AND delstate='' AND checkinfo=true ORDER BY orderid DESC LIMIT 0,100");
{
$num = array();
while($row = $dosql->GetArray())
echo $ss = $row['keywords']; //输出 你好,你好,你好,不好,很好
echo $num= $ss; //输出 很好

   //目标把 $ss 赋值给 $num 循环出来
$num[] = $row['keywords'];

}
var_dump($num);</code>
Copy after login

<code>$ss = count($row['key']); 
$num=count($ss) //这里$ss不是一个数组了,count(非数组)只会输出0(null时)和1</code>
Copy after login

第一次count完就是一个int型的数值。看不懂题主想要干嘛。

这里的 1 会默认做 int 处理的

Related labels:
php
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template