Home >Backend Development >PHP Tutorial >tp数组输出,该怎么解决

tp数组输出,该怎么解决

WBOY
WBOYOriginal
2016-06-13 12:03:571113browse

tp数组输出
数组一

<br />array (size=6)<br />  10 => string '准备买' (length=9)<br />  11 => string '不准备换' (length=12)<br />  12 => <br />    array (size=2)<br />      0 => string '3厢小轿车' (length=13)<br />      1 => string '城市SUB' (length=9)<br />  13 => string '33333' (length=5)<br />  14 => <br />    array (size=2)<br />      0 => string '中型' (length=6)<br />      1 => string '小巧型' (length=9)<br />  15 => string '全险' (length=6)<br />

数组二
<br />array (size=6)<br />  0 => <br />    array (size=11)<br />      'id' => string '10' (length=2)<br />      'wjb_title' => string '请问你现在有车吗?' (length=27)<br /><br />  1 => <br />    array (size=11)<br />      'id' => string '11' (length=2)<br />      'wjb_title' => string '请问您近期准备换车吗?' (length=33)<br /><br />  2 => <br />    array (size=11)<br />      'id' => string '12' (length=2)<br />      'wjb_title' => string '你喜欢什么类型的车?' (length=30)<br /><br />  3 => <br />    array (size=11)<br />      'id' => string '13' (length=2)<br />      'wjb_title' => string '你购车用途' (length=15)<br /><br />  4 => <br />    array (size=11)<br />      'id' => string '14' (length=2)<br />      'wjb_title' => string '你喜欢SUV中的哪一款' (length=27)<br /><br />  5 => <br />    array (size=11)<br />      'id' => string '15' (length=2)<br />      'wjb_title' => string '你购车主要用在' (length=21)<br /><br />


{$vo.wjb_title}
当id=数组一的键值,读取键值对的数据;
例如id=10就读取10 => string '准备买' (length=9)里的值?

------解决方案--------------------
很久没用TP了,不知道语法是不是有问题。 思路如下。volist  里面再加一个volist  判断KEY值是否相等。相等则输出数组一里面的title

{$vo.wjb_title}


{$v.title}


------解决方案--------------------
建议使用源生的php来写 ,TP的标签最后也是解析成源生的php,而且代码量相当,速度也会更快

<br /><?php <br />		foreach ($arr1 as $key => $value) {<br />			foreach ($arr2 as $k => $v) {<br />				if ($value['id'] == $k)<br />				{<br />					print_r($v);<br />				}<br />			}<br />		}<br />	 ?><br />

------解决方案--------------------

    
        {$it}
    


这个吧
数组一里面有些是二维数组,碰到这个情况,输出的是Array,这时候你还得再做个值选择。

Statement:
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