Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
循环中的PHP返回数组_Php_Arrays - Fatal编程技术网

循环中的PHP返回数组

循环中的PHP返回数组,php,arrays,Php,Arrays,我正在创建一个循环记录的函数,并希望返回项目数组 if(!function_exists("TicketAttachments")) { function TicketAttachments($update_sequence) { global $conn, $pdo_conn; $results = array(); $sql="SELECT * from ticket_updates where ticketnumber = '".$

我正在创建一个循环记录的函数,并希望返回项目数组

if(!function_exists("TicketAttachments")) {
    function TicketAttachments($update_sequence) {
        global $conn, $pdo_conn;

        $results = array();
        $sql="SELECT * from ticket_updates where ticketnumber = '".$update_sequence."' and type = 'attachment' ";
        $rs=mysql_query($sql,$conn);
        while($result=mysql_fetch_array($rs)) {
            $results["link"] = 'media/ticket_attachments/'.$result["notes"];
            $results["name"] = $result["notes"];
        }

        return $results;
    }
}
我在这里称之为:

$attachments = TicketAttachments($TicketUpdate["sequence"]);
foreach($attachments as $att) {
    echo $att["name"];
}
但这是呼应
h5
而name=
55388-20150929124302-screen dump 28092015.docx

我想你需要合并这个数组

我想你需要合并这个数组


停止使用不推荐的函数<代码>$att[“名称”]此行没有任何作用。你的意思是
echo
?检查我的更新-这就是我的更新方式。我一直在测试,但忘了将其添加回,而不是使用不推荐的函数<代码>$att[“名称”]此行没有任何作用。你的意思是
echo
?检查我的更新-这就是我的更新方式。我一直在测试,却忘了把它加回去
if(!function_exists("TicketAttachments")) {
    function TicketAttachments($update_sequence) {
        global $conn, $pdo_conn;

        $results = array();
        $sql="SELECT * from ticket_updates where ticketnumber = '".$update_sequence."' and type = 'attachment' ";
        $rs=mysql_query($sql,$conn);
        while($result=mysql_fetch_array($rs)) {
            $results[] = array(
                "link"=>'media/ticket_attachments/'.$result["notes"],
                "name" => $result["notes"];
            );
        }
        return $results;
    }
}