我創(chuàng)建了 js 樹,我面臨的問題是如何在數(shù)組的同一行顯示兩列數(shù)據(jù)?以下是我的輸出:輸出這是我的編碼,我的問題是如何在此"text" => $row['name'],行添加 $row['category'] 。<?php $folderData = mysqli_query($mysql_con,"SELECT * FROM folder_category where status=1"); $folders_arr = array(); while($row = mysqli_fetch_assoc($folderData)){ $parentid = $row['parentid']; if($parentid == '0') $parentid = "#"; $selected = false;$opened = false; if($row['id'] == 2){ $selected = true;$opened = true; } $folders_arr[] = array( "id" => $row['id'], "parent" => $parentid, "text" => $row['name'], //how I can add $row['category'] at this same line. "state" => array("selected" => $selected,"opened"=>$opened) ); } ?> <!-- Initialize jsTree --> <div id="folder_jstree" title="JTM"></div> <!-- Store folder list in JSON format --> <textarea style="" id='txt_folderjsondata'><?= json_encode($folders_arr) ?></textarea><script>$(document).ready(function(){ var folder_jsondata = JSON.parse($('#txt_folderjsondata').val()); $('#folder_jstree').jstree({ 'core' : { 'data' : folder_jsondata, 'multiple': false } });});</script>然后輸出將像下面的示例圖片一樣,所以我希望將 $row['category'] 放在同一行的 $row['name'] 后面: Output3下面是我的表格信息: 輸出 4希望有人能指導(dǎo)我解決這個問題。謝謝。
1 回答

慕尼黑5688855
TA貢獻1848條經(jīng)驗 獲得超2個贊
只需連接兩個字符串。
[
...
'text' => $row['name'] . ' ' . $row['category'],
...
]
- 1 回答
- 0 關(guān)注
- 181 瀏覽
添加回答
舉報
0/150
提交
取消