📄 00000025.htm
字号:
<HTML><HEAD> <TITLE>BBS水木清华站∶精华区</TITLE></HEAD><BODY><CENTER><H1>BBS水木清华站∶精华区</H1></CENTER>发信人: thinkin (强强), 信区: Linux <BR>标 题: Print Array <BR>发信站: BBS 水木清华站 (Thu Feb 17 11:05:36 2000) <BR> <BR><?php <BR>/* FIRETAIL-print_array <BR> * Copyright (C) 1999 Scott Parish <BR> * <BR> * This library is free software; you can redistribute it and/or <BR> * modify it under the terms of the GNU Library General Public <BR> * License as published by the Free Software Foundation; either <BR> * version 2 of the License, or (at your option) any later version. <BR> * <BR> * This library is distributed in the hope that it will be useful, <BR> * but WITHOUT ANY WARRANTY; without even the implied warranty of <BR> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU <BR> * Library General Public License for more details. <BR> * <BR> * You should have received a copy of the GNU Library General Public <BR> * License along with this library; if not, write to the <BR> * Free Software Foundation, Inc., 59 Temple Place - Suite 330, <BR> * Boston, MA 02111-1307, USA. <BR> */ <BR>//This is are two little functions that I made to quickly debug my arrays <BR>//while making php scripts. You can pass these things any variable (both <BR>//arrays and non arrays), and it will print out everything that is in it. <BR>//It will even print out embedded arrays, so if you have arrays in arrays <BR>//in arrays, it will print all that out in a consice enough format that you <BR>//will know exactly what is in that variable. <BR>// <BR>//You should get output with "key => val", which should look something like <BR>//the following: <BR>// <BR>// admin => <BR>// user => 1 <BR>// screwball => 2 <BR>// admin => 4 <BR>// . . . <BR>// is => <BR>// student worker => 1 <BR>// hacker => 2 <BR>// nerd => 4 <BR>// admin => 8 <BR>// . . . <BR>// <BR>//call it like the following (where $testVar is a variable of you choice) <BR>// <BR>// print_array($testVar); <BR>// <BR>//if your array contains any html code, you may want to call it instead as: <BR>// <BR>// print_array($testVar,"<xmp>","</xmp>"); <BR>// <BR>//Should be very easy to throw in your code and use...hope you find it useful <BR>// Scott Parish <<A HREF="mailto:sRparish@bigfoot.com>">sRparish@bigfoot.com></A> 1998/02/24 <BR> <BR>if(!$GLOBALS[ "PRINT_ARRAY"]) { <BR> <BR> $GLOBALS[ "PRINT_ARRAY"]=true; <BR> function print_array($a,$btag= "",$etag= "") { <BR> if(is_array($a)) { <BR> printf( "<table cellpadding=0 cellspacing=0>"); <BR> while(list($one,$two)=each($a)) { <BR> printf( "\n<tr valign=baseline><td>$btag$one$etag</td><td>". <BR> "&nbsp;$btag=>$etag</td>". <BR> "<td align=right>&nbsp;%s</td></tr>\n" <BR> ,sprint_array($two,$btag,$etag)); <BR> } <BR> printf( "</table>"); <BR> } <BR> else { <BR> printf( "%s%s%s",$btag,$a,$etag); <BR> } <BR> } <BR> <BR> <BR> <BR> <BR> function sprint_array($a,$btag= "",$etag= "") { <BR> if(is_array($a)) { <BR> $out=sprintf( "<table cellpadding=0 cellspacing=0>"); <BR> while(list($one,$two)=each($a)) { <BR> $out .= sprintf( "\n<tr valign=baseline><td>$btag$one$etag</td><td>". <BR> "&nbsp;$btag=>$etag</td>". <BR> "<td align=right>&nbsp;%s</td></tr>\n" <BR> ,sprint_array($two,$btag,$etag)); <BR> } <BR> $out .= "</table>"; <BR> return $out; <BR> } <BR> else { <BR> return sprintf( "%s%s%s",$btag,$a,$etag); <BR> } <BR> } <BR>} <BR>?> <BR>-- <BR> <BR>人生到处知何似? <BR> 应似飞鸿踏雪泥。 <BR> 泥上偶然留指爪, <BR> 鸿飞那复计东西! <BR> <BR> <BR>※ 来源:·BBS 水木清华站 smth.org·[FROM: 162.105.37.191] <BR><CENTER><H1>BBS水木清华站∶精华区</H1></CENTER></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -