Home > Backend Development > PHP Tutorial > 数据有关问题请问!

数据有关问题请问!

WBOY
Release: 2016-06-13 10:15:35
Original
933 people have browsed it

数据问题请教!!
有这样一个结果,,0 2 4 偶然 是标题, 1,3,5 是这个标题的 ID

Array
(
  [0] => 今天吃了吗!
  [1] => 2
  [2] => 今天不吃了!
  [3] => 3
  [4] => 今天真饿啊!
  [5] => 8
)

怎么处理可以在模板得到 



今天不吃了! (id=3)




------解决方案--------------------
有这样一个结果,,0 2 4 偶然 是标题, 1,3,5 是这个标题的 ID
------解决方案--------------------

PHP code
$ar = array(  0 => '今天吃了吗!',  2,  '今天不吃了!',  3,  '今天真饿啊!',  8,);foreach(array_chunk($ar, 2) as $v)  $list[] = array( 'id' => $v[1], 'name' => $v[0] );print_r($list);<br><font color="#e78608">------解决方案--------------------</font><br>
Copy after login
PHP code
$array = array('标题1', 'id1', '标题2', 'id2', '标题3', 'id3');foreach ($array as $key => $value) {    if (isset($array[$key + 1]))        $id = $array[$key + 1];    echo '<a href="?id='%20.%20%24id%20.%20'">' . $value . '</a> (id=' . $id . ')<br>';}<br><font color="#e78608">------解决方案--------------------</font><br>
Copy after login
PHP code
$array=array();$arrList=array();for($i=0; $i<count as echo href="?id=%24lists%5B" id>$lists['title']";}<br><font color="#e78608">------解决方案--------------------</font><br><dl class="code">PHP code<pre class="brush:php;toolbar:false">$array = array('id1','标题1','id2','标题2','id3','标题3');foreach(range(1,count($array)*1/2) as $val){    echo "<a href="?id=%22.current(%24array).%22">".next($array)."</a>\r\n";    next($array);}<div class="clear">
                 
              
              
        
            </div>
Copy after login
Related labels:
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