Re: RE: Printing structure and data of array
| From: | matthias dot stache at gmx dot de | Date: | Tue, 22 Jan 2002 13:30:03 +0000 |
| Subject: | Re: RE: Printing structure and data of array | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-81538@lists.php.net to get a copy of this message | ||
how about:
function debugPrint($mVar, $bHtml) {
global $HTTP_REFERER;
if (is_array($mVar)){
$sTemp = "Array";
}
if (is_bool($mVar)){
$sTemp = "Bool";
}
[snip]
...
$sFunction = "debugPrint$sTemp"; //getting the function to call to
$sFunction($sTemp,$mVar,$bHtml); //calls the fuction
}
function debugPrintArray($sTemp,$mVar,$bHtml){
$sInfo = "<br>type: " . $sTemp;
if ($bHtml){
echo "<br><u>key=>value</u>";
foreach($mVar as $sKey => $sValue) {
$aFormData[$sKey] = $sValue;
echo "<br><u>".$sKey . " => </u>";
echo "<u>".$sValue . "</u>";
debugPrint($sValue,1);
}
} else {
$sInfo = "\ntype: " . $sTemp;
echo "key -- value\n";
foreach($mVar as $sKey => $sValue) {
$aFormData[$sKey] = $sValue;
echo "\n".$sKey . " = ";
echo $sValue;
debugPrint($sValue,1);
}
}
echo $sInfo;
}
function debugPrintBool($sTemp,$mVar,$bHtml){
if ($bHtml){
[snip]
I'm not sure, the output 100% right but it should show how to use it.
I attached the .php file.
Greets
----- Original Message -----
From: "Sandeep Murphy" <Sandeep.Murphy@oni.pt>
To: <matthias.stache@gmx.de>; "PHP List" <php-general@lists.php.net>
Sent: Tuesday, January 22, 2002 1:51 PM
Subject: RE: [PHP] RE: Printing structure and data of array
> hi,
>
> Thnx for the info but this is what I am using right now... It prints the
> contents of array one below the other... is not showing the format of the
> contents as i want...:(
>
> any more suggestions??
>
> thnx,
> sands
>
> -----Original Message-----
> From: matthias.stache@gmx.de [mailto:matthias.stache@gmx.de]
> Sent: terça-feira, 22 de Janeiro de 2002 12:43
> To: PHP List
> Subject: Re: [PHP] RE: Printing structure and data of array
>
>
> Use this:
>
>
> function debugPrint($mVar, $bHtml) {
> if ($bHtml){
> echo "<pre>";
> print_r ($mVar);
> echo "</pre>";
> } else {
> print_r ($mVar);
> }
> }
>
> call it like this:
>
> debugPrint($yourVariable,1);
>
>
> This will print out any type (object,array,ressource,string...)
>
> ----- Original Message -----
> From: "Sandeep Murphy" <Sandeep.Murphy@oni.pt>
> To: "'Tim Ward'" <Tim.ward@stivesdirect.com>; "PHP List"
> <php-general@lists.php.net>
> Sent: Tuesday, January 22, 2002 1:00 PM
> Subject: RE: [PHP] RE: Printing structure and data of array
>
>
> > hi,
> >
> > how can I display the array exactly as it is the format specified???
like
> if
> > their exists sub elements of elements, how could I represent them in a
> > multidimensional format??
> >
> > I went thru most of the array functions but unable to adapt any of
them..
> >
> > pl help..
> >
> > TIA,
> > sands
> >
> > -----Original Message-----
> > From: Tim Ward [mailto:Tim.ward@stivesdirect.com]
> > Sent: segunda-feira, 21 de Janeiro de 2002 10:24
> > To: PHP List; Daniel Alsén
> > Subject: [PHP] RE: Printing structure and data of array
> >
> >
> > Foreach($array as $key=>$value) ech0("$key=>$value<br>");
> >
> > Tim
> > www.chessish.com <http://www.chessish.com>
> >
> > ----------
> > From: Daniel Alsén [SMTP:d@mindbash.com]
> > Sent: 20 January 2002 19:33
> > To: PHP List
> > Subject: Printing structure and data of array
> >
> > Hi,
> >
> > i know i have this answered before. But i can´t find that mail in
> > the
> > archive.
> >
> > How do i print an array to see both the structure and the data
> > within?
> > ("test" => "value", "test2" => "value2")...
> >
> > # Daniel Alsén | www.mindbash.com #
> > # d@mindbash.com | +46 704 86 14 92 #
> > # ICQ: 63006462 | +46 8 694 82 22 #
> > # PGP: http://www.mindbash.com/pgp/ #
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> > For additional commands, e-mail: php-general-help@lists.php.net
> > To contact the list administrators, e-mail: php-list-admin@lists.php.net
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> > For additional commands, e-mail: php-general-help@lists.php.net
> > To contact the list administrators, e-mail: php-list-admin@lists.php.net
> >
> >
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>
>