Re: [PHP] array simple question
tray print the array this way: echo 'pre'; print_r($array); echo '/pre'; -afan matt VanDeWalle wrote: hello, I have a simple question, not really a problem this time. I know that the function print_r() will print an array but if that array has sub-arrays it prints everything and if you don't use more command or a pipe of some kind that could be useless in some cases, but I am just wondering, for an array that has several arrays in it, is there a way to print the array names that are contained in the main array but not the contents of each? thanks matt -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] array simple question
please provide code and an example output, and say how this is different than you would like. what you describe is unclear. Jordan On Sep 13, 2005, at 4:04 PM, matt VanDeWalle wrote: hello, I have a simple question, not really a problem this time. I know that the function print_r() will print an array but if that array has sub-arrays it prints everything and if you don't use more command or a pipe of some kind that could be useless in some cases, but I am just wondering, for an array that has several arrays in it, is there a way to print the array names that are contained in the main array but not the contents of each? thanks matt -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] array simple question
matt VanDeWalle wrote: hello, I have a simple question, not really a problem this time. I know that the function print_r() will print an array but if that array has sub-arrays it prints everything and if you don't use more command or a pipe of some kind that could be useless in some cases, but I am just wondering, for an array that has several arrays in it, is there a way to print the array names that are contained in the main array but not the contents of each? Note: untested code, and this preserves keys, which you might not want. It's reasonably simple to change it to not preserve keys. ?php $array = array( 'this', 'is', 'my', array( 'array' ) ); $newArray = array(); foreach( $array as $key=$value ) { if( !is_array( $value ) ) { $newArray[$key] = $value; } } print( 'pre' . print_r( $newArray, true ) . '/pre' ); ? -- Jasper Bryant-Greene Freelance web developer http://jasper.bryant-greene.name/ If you find my advice useful, please consider donating to a poor student! You can choose whatever amount you think my advice was worth to you. http://tinyurl.com/7oa5s -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] array simple question
If you want to print the keys for all the arrays in the main array then use allkeys. matt VanDeWalle wrote: hello, I have a simple question, not really a problem this time. I know that the function print_r() will print an array but if that array has sub-arrays it prints everything and if you don't use more command or a pipe of some kind that could be useless in some cases, but I am just wondering, for an array that has several arrays in it, is there a way to print the array names that are contained in the main array but not the contents of each? thanks matt -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php