View Single Post
  #1  
Old 05-23-2007, 03:49 AM
 
TTS Telecom TTS Telecom is offline
 

Member
  
Join Date: Dec 2003
Location: SW, UK
Posts: 17
 

Cool 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
__________________
X-cart: 4.0.17
PHP: 4.3.11
Reply With Quote