Using foreach
loop without key
foreach($array as $item) { echo $item['filename']; echo $item['filepath']; // to know what's in $item echo '<pre>'; var_dump($item); }
Using foreach
loop with key
foreach($array as $i => $item) { echo $item[$i]['filename']; echo $item[$i]['filepath']; // $array[$i] is same as $item }
Using for
loop
for ($i = 0; $i < count($array); $i++) { echo $array[$i]['filename']; echo $array[$i]['filepath']; }
var_dump
is a really useful function to get a snapshot of an array or object.
Related Posts:
- How to add elements to an empty array in PHP?
- PHP array printing using a loop
- Convert hex color to RGB values in PHP
- Calculate business days
- For-each over an array in JavaScript
- How do I make a redirect in PHP?
- Difference between “as $key => $value” and “as $value” in PHP foreach
- Loop through an array in JavaScript
- Loop through an array in JavaScript
- What do ++ and *+ mean?
- Array to String PHP?
- What’s the simplest way to print a Java array?
- What’s the net::ERR_HTTP2_PROTOCOL_ERROR about?
- Undefined function mysql_connect()
- MySQL column count doesn’t match value count at row 1 [closed]
- What’s the simplest way to print a Java array?
- Matching a space in regex
- Undefined function mysql_connect()
- How can I send an email using PHP?
- Fatal error: Call to undefined function mysql_connect()
- count() parameter must be an array or an object that implements countable in laravel
- Go Back to Previous Page
- How do I check if a string contains a specific word?
- How do I replace part of a string in PHP? [duplicate]
- How to declare a global variable in php?
- How to fix “Headers already sent” error in PHP
- Fatal error: Call to undefined function mysql_connect()
- “Notice: Undefined variable”, “Notice: Undefined index”, and “Notice: Undefined offset” using PHP
- How to fix ‘Notice: Undefined index:’ in PHP form action
- How to print the array?
- “Notice: Undefined variable”, “Notice: Undefined index”, and “Notice: Undefined offset” using PHP
- Print ArrayList
- Print ArrayList
- Form submission: PHP S_SESSION statements within a foreach loop
- Deprecated: mysql_connect()
- Where does PHP store the error log? (PHP 5, Apache, FastCGI, and cPanel)
- Java – Best way to print 2D array?
- Why is using “for…in” for array iteration a bad idea?
- Convert a PHP object to an associative array
- How to echo or print an array in PHP?
- Chrome net::ERR_INCOMPLETE_CHUNKED_ENCODING error
- Correct way of looping through C++ arrays
- How can I write to the console in PHP?
- Illegal string offset Warning PHP
- Print ArrayList
- What is PHPSESSID?
- MySQL “Or” Condition
- What is the significance of the number, 32767?
- PHP – how to create a newline character?
- Java – Best way to print 2D array?
- Fill array with random numbers within a specified range (C++)
- How to add a line break within echo in PHP?
- Deleting an element from an array in PHP
- How to insert an item at the beginning of an array in PHP?
- How to solve PHP error ‘Notice: Array to string conversion in…’
- Printing an array in C++?
- what is a good method to sanitize the whole $_POST array in php?
- Sort array of objects by object fields
- Bubble sort algorithm in MIPS
- In_array not working
- extended initializer lists only available with
- Bank Account Java Program
- PHP multidimensional array search by value
- Fatal error: Cannot use object of type mysqli_result
- php foreach with multidimensional array
- Convert php array to Javascript
- How to read a large file line by line?
- PHP reindex array?
- Best way to do multiple constructors in PHP
- php – How do I fix this illegal offset type error
- Mysql where id is in array
- How to convert array to SimpleXML
- Create a two dimensional string array anArray[2][2]
- What is the “right” way to iterate through an array in Ruby?
- How to iterate through table in Lua?
- Array of PHP Objects
- Is there a function to make a copy of a PHP array to another?
- How to Sort a Multi-dimensional Array by Value
- Fastest way to implode an associative array with keys
- PHP array delete by value (not key)
- Printing from a declared array in MIPS
- PHP Multiple Checkbox Array
- Display array values in PHP
- Reset PHP Array Index
- How to push both value and key into PHP array
- Remove empty array elements
- Exclude Featured Posts in WordPress ‘Recent Posts’ Function
- What does arg mean in WordPress
- How to get URL of current page displayed?
- Undefined variable in functions.php file [closed]
- What are PHP extensions and libraries WP needs and/or uses?
- What is the correct way to use WordPress functions outside WordPress files?
- Allow HTML in excerpt
- How to get WordPress Time Zone setting?
- how to get page id of a page using page slug
- Check if current page is the Blog Page
- How to set and use global variables? Or why not to use them at all
- Sending the reset password link programatically
- How to add product in woocommerce with php code [closed]
- Show all terms of a custom taxonomy?