Skip to main content
additional info
Source Link
Marius
  • 198.5k
  • 55
  • 424
  • 833
Mage::log(print_r($arr, 1), null, 'logfile.log');

Adding a second parameter to print_r will return a string with printed variable.
[EDIT]
based on the comments below I feel obligated to offer other options for logging an array.

Mage::log($arr, null, 'logfile.log');

or if you need a string prefix to the array

Mage::log('prefix'.Zend_Debug::dump($arr, null, false), null, 'logfile.log');

The second parameter of Zend_Debug::dump() is a label. If this is not null it will be added to before the array dump.
The third parameter of Zend_Debug::dump() means echo. If it's true then the dump result will be echoed, if it's false it will be returned as a string. In your case you need it to be false.

Mage::log(print_r($arr, 1), null, 'logfile.log');

Adding a second parameter to print_r will return a string with printed variable.

Mage::log(print_r($arr, 1), null, 'logfile.log');

Adding a second parameter to print_r will return a string with printed variable.
[EDIT]
based on the comments below I feel obligated to offer other options for logging an array.

Mage::log($arr, null, 'logfile.log');

or if you need a string prefix to the array

Mage::log('prefix'.Zend_Debug::dump($arr, null, false), null, 'logfile.log');

The second parameter of Zend_Debug::dump() is a label. If this is not null it will be added to before the array dump.
The third parameter of Zend_Debug::dump() means echo. If it's true then the dump result will be echoed, if it's false it will be returned as a string. In your case you need it to be false.

edited body
Source Link
Marius
  • 198.5k
  • 55
  • 424
  • 833
Mage::log(print_r($arr., 1), null, 'logfile.log');

Adding a second parameter to print_r will return a string with printed variable.

Mage::log(print_r($arr. 1), null, 'logfile.log');

Adding a second parameter to print_r will return a string with printed variable.

Mage::log(print_r($arr, 1), null, 'logfile.log');

Adding a second parameter to print_r will return a string with printed variable.

Source Link
Marius
  • 198.5k
  • 55
  • 424
  • 833

Mage::log(print_r($arr. 1), null, 'logfile.log');

Adding a second parameter to print_r will return a string with printed variable.