X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (https://forum.x-cart.com/forumdisplay.php?f=20)
-   -   X_cart Variable Array String Debug Tool (https://forum.x-cart.com/showthread.php?t=31363)

TTS Telecom 05-23-2007 03:49 AM

X_cart Variable Array String Debug Tool
 
Have no idea if this is of any use to any one here, I wrote this to quickly find the info i wanted in side strings, I use it alot with X-cart.

Function:
Basically if you want to know what values/keys are held in a string, use this, it's a bit like a neat explode()

just include the function in /includes/func.php

or on the page you want to use it on

Really simple to use
Code:

getVariables($string, $email_debug);

$string is the string you wish to debug
$email_debug is the email you want the output sent to

produces an out put like this (emailed to your desired address)

Code:

*********************
KEY: products
***********************
[products] [0] [itemid] = 1470
[products] [0] [productid] = 16371
[products] [0] [productcode] = TEST
[products] [0] [product] = product name test download
[products] [0] [provider] = master
[products] [0] [distribution] = /c_249.gif
[products] [0] [weight] = 0.00
[products] [0][list_price] = 10.00
[products] [0] [descr] = short description text
[products] [0] [fulldescr] = detailed description text
[products] [0] [avail] = 1000
[products] [0] [rating] = 13
[products] [0] [forsale] = H
[products] [0] [add_date] = 1179608145
[products] [0] [image_x] = 0
[products] [0] [image_y] = 0

etc ......................................................


Heres the function

Code:

function getVariables($string, $email_debug)
{
        foreach ($string as $key => $value)
{
        $body .= "\n*********************\nKEY: $key\n***********************";
        $current = $key;
        if (is_array($value))
        {
                foreach ($value as $key => $value)
        {
                $current1 = $key;
                if (is_array($value))
                {
                        foreach ($value as $key => $value)
                        {
                                $body .= "\n[$current] [$current1] [$key] = $value";
                        }
                }
                $body .= "\n[$current] [$key] = $value";
                }
        }
        else
        {
                $body .= "\n[$key] = $value";
        }
        }

$subject = 'order data on look at order history';
$to = $email_debug;    //  your email
mail($to, $subject, $body);
}


All the best


Jethro

Zaja 05-23-2007 04:34 AM

Re: X_cart Variable Array String Debug Tool
 
Nice one Jethro, thx.


All times are GMT -8. The time now is 11:31 AM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.