Home  >  Article  >  Backend Development  >  PHP二维数组输出

PHP二维数组输出

WBOY
WBOYOriginal
2016-06-23 14:00:481698browse

把定义好数组后按URL传值的结果输出数组。如接收传值name=baidu,则按html格式输出baidu数组。请问如何实现?

<?php   $b-title = baidu;   $b-keyword = search;   $b-content = baidu search;    $g-title = google;   $g-keyword = search;   $g-content = google search; $baidu=array('baidu'=>array('$b-title','$b-keyword','$b-content'));$google=array('google'=>array('$g-title','$g-keyword','$g-content'));?>输出:<html>    <head>        <title></title>       <meta name="keywords" content="" />    </head>    <body>        </body></html>


回复讨论(解决方案)

变量:数字、字母、下划线
字符串:引号括起来。

变量:数字、字母、下划线
字符串:引号括起来。
   $btitle = "baidu";
   $bkeyword = "search";
   $bcontent = "baidu search"; 
   $gtitle = "google";
   $gkeyword = "search";
   $gcontent = "google search"; 
$baidu=array('baidu'=>array('$btitle','$bkeyword','$bcontent'));
$google=array('google'=>array('$gtitle','$gkeyword','$gcontent'));
?>

$b_title = 'baidu';	$b_keyword = 'search';	$b_content = 'baidu search'; 	$baidu = array('b-title'=>$b_title,'b-keyword'=>$b_keyword,'b-content'=>$b_content);	echo http_build_query($baidu);

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
Previous article:php怎么捕获异常?Next article:php 无法连接 memcache