Printing Associative Arrays, How to Log Out an Associative Array, Use implode and print_r function

In this PHP programming lesson, we take a look at Printing Associative Arrays, How to Log Out an Associative Array, Use implode and print_r function. In this lesson, we continue our journey into the world of associative arrays in PHP. We begin how to learn how to print out our arrays so we can visually get an idea of what kind of data we are working with inside of our array. We learn that we are able to use the implode() function as well as the print_r() function to see the contents of our associative arrays. When we use implode in PHP, we combine it with echo to print the values of our associative array. Remember that the PHP implode() function takes two arguments. The first argument is what separates each element that is iterated through and printed out, so we use a “, ” (comma with a space) so that each value that is printed out is separated by a comma with a space. When we use the implode function it will only print out the values of the array we provide. If we also want to access the keys, then using the print_r function may be your go-to! The print_r function will help us display both keys and values of the array we provide it. Learning to use the right one will become more obvious with practice and do make sure to practice displaying array data with both implode and print_r. Thanks for watching Printing Associative Arrays, How to Log Out an Associative Array, Use implode and print_r function.