请高手帮忙看一下,为什么这个循环只执行一次就不执行了
$list是一个二维数组,存放由数据库取来的记录,
程序的目的是:根据每条记录中获取到的regionid得到regionname并将其添加到数组中.
现在的问题是:这个循环每次只能输出一条记录.
$this->get_region可以正常工作,在输出的一条记录里,可以获取到内容.
类中有问题的一段代码:
$list = array();
while ($row = $this -> db -> fetch_assoc()) {
$row['regionname'] = $this -> get_region($row['regionid']);
$list[] = $row;
}
------解决方案--------------------
print_r($list);
我想看看到底都是啥东西.
------解决方案--------------------
print_r($list); 看看输出什么结果

List操作//从list头部插入一个值。$ret=$redis->lPush('city','guangzhou');//从list尾部插入一个值。$ret=$redis->rPush('city','guangzhou');//获取列表指定区间中的元素。0表示列表第一个元素,-1表示最后一个元素,-2表示倒数第二个元素。$ret=$redis->l

1:JSONArray转ListJSONArray字符串转List//初始化JSONArrayJSONArrayarray=newJSONArray();array.add(0,"a");array.add(1,"b");array.add(2,"c");Listlist=JSONObject.parseArray(array.toJSONString(),String.class);System.out.println(list.to

如何使用C#中的List.Sort函数对列表进行排序在C#编程语言中,我们经常需要对列表进行排序操作。而List类的Sort函数正是为此设计的一个强大工具。本文将介绍如何使用C#中的List.Sort函数对列表进行排序,并提供具体的代码示例,帮助读者更好地理解和应用该函数。List.Sort函数是List类的一个成员函数,用于对列表中的元素进行排序。该函数接

一、List接口简介List是一个有序的集合、可重复的集合。它是继承Collection接口,在List集合中是可以出现重复的元素,可以通过索引(下标)来访问指定位置的元素。二、List常用方法——voidadd(intindex,Obejctelement)方法1.voidadd(intindex,Obejctelement)方法是把element元素插入在指定位置,后面的元素往后移一个元素。2.voidadd(intindex,Obejctelemen

一.最常见方式(未必最佳)通过Arrays.asList(strArray)方式,将数组转换List后,不能对List增删,只能查改,否则抛异常。关键代码:Listlist=Arrays.asList(strArray);privatevoidtestArrayCastToListError(){String[]strArray=newString[2];Listlist=Arrays.asList(strArray);//对转换后的list插入一条数据list.add("1"

示例在这个例子中,我们先看看list.sort()的用法,然后再继续。在这里,我们创建了一个列表并使用sort()方法按升序排序-#CreatingaListmyList=["Jacob","Harry","Mark","Anthony"]#DisplayingtheListprint("List=",myList)#SorttheListsinAscendingOrdermyList.sort(

前言在Java中的常用的集合接口List中有两个非常相似的方法:Eset(intindex,Eelement);voidadd(intindex,Eelement);这两个方法都是在集合的指定位置插入指定的元素,那么这两个方法到底有什么区别呢?接下来我们通过ArrayList这个我们常用集合实现来看一下这两个方法的差异相同点首先我们来看一下这两个方法在ArrayList中的相同点他们都会在集合的指定位置插入新的元素,例如下面的例子:#在集合的第2位插入一个F#通过add方法插入Listlist=

第一步:导入依赖com.google.code.gsongson2.8.6第二步:开始使用场景一:转换普通对象(Bean)。1.将普通的JavaBean转换为Json字符串是最常用的操作了,首先创建一个简单的类,例如:Person。publicclassPerson{privateStringname;privateintage;privatebooleanisMale;privateListhobbies;//省略构造器和getter/setter方法,注意重写toString方法,便于查看控


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SublimeText3 Chinese version
Chinese version, very easy to use

SublimeText3 Mac version
God-level code editing software (SublimeText3)

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Dreamweaver CS6
Visual web development tools

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software
