Jump to content


Photo

how to see what is in an array(ALL FIXED THANKS ALL)


  • Please log in to reply
6 replies to this topic

#1 keithschm

keithschm
  • Members
  • PipPipPip
  • Advanced Member
  • 34 posts

Posted 06 October 2006 - 01:52 PM

I have an array and I am not sure what is in it or how deep it is or what the seperater is.  is there any way to just dump an array?

if you echo the array it displays ARRAY
if I use explode  I get nothing as I m not sure what the seperater is


Thanks
NEED HELP

#2 printf

printf
  • Staff Alumni
  • Advanced Member
  • 889 posts

Posted 06 October 2006 - 01:56 PM


print_r ( $array );

or

var_dump ( $array );


me!

#3 Daniel0

Daniel0
  • Staff Alumni
  • Advanced Member
  • 11,956 posts

Posted 06 October 2006 - 02:04 PM

You can use var_export as well. It will output it as the way you would define it in PHP.

That could be useful for editing configuration files consisting of an array.

#4 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 06 October 2006 - 02:37 PM

If you want the output from any of those functions to be readable in the browser window, surround them with <pre></pre> tags. For example:
<?php
echo '<pre>' . print_r($somearray,true) . '</pre>';
?>

Ken

#5 keithschm

keithschm
  • Members
  • PipPipPip
  • Advanced Member
  • 34 posts

Posted 06 October 2006 - 03:03 PM

WOW

thank you all so much for your help.

now this array seems very comlicated to me as it looks like arrays inside arrays


Array
(
    [0] => Array
        (
            [1DA] => 27.84
        )

    [1] => Array
        (
            [1DP] => 24.23
        )

    [2] => Array
        (
            [2DA] => 14.33
        )

    [3] => Array
        (
            [3DS] => 10.60
        )

    [4] => Array
        (
            [GND] => 6.65
        )

)


it is the return values for ups quotes.  I need to alter it.  the text is the shipping type and the numbers is the cost.  I need to subtract the value associted with the GND  from all the other vales in the array

I tried "for each" but I am lost

any sugestion

thanks


NEED HELP

#6 HuggieBear

HuggieBear
  • Members
  • PipPipPip
  • Advanced Member
  • 1,899 posts
  • LocationEngland, UK

Posted 06 October 2006 - 03:50 PM

How are you propogating the array?

Regards
Huggie
Advice to MySQL users: Get phpMyAdmin and test your queries work there first, take half the hassle out of diagnosis, also check the reserved words list.

Links: PHP Docs :: RegEx's :: MySQL :: DevGuru :: w3schools

#7 keithschm

keithschm
  • Members
  • PipPipPip
  • Advanced Member
  • 34 posts

Posted 06 October 2006 - 04:05 PM

How are you propogating the array?

Regards
Huggie


what do you mean?
NEED HELP




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users