Usevar_dump()Function to Echo or Print an Array in PHP Thevar_dump()function is used to print the details of any variable or expression. It prints the array with its index value, the data type of each element, and length of each element. It provides the structured information of the ...
CSS Language Course 4.5(306+) | 3.3k users HTML Course 4.7(2k+ ratings) | 13.5k learners About the author: Abhishek Ahlawat I am the founder of Studytonight. I like writing content about C/C++, DBMS, Java, Docker, general How-tos, Linux, PHP, Java, Go lang, Cloud, and Web developm...
<?php$arr=array("This","is","an","array");$string=implode(" ",$arr);echo"The array is converted to the string.";echo"\n";echo"The string is '$string'";?> Here we have passed a white space string as a separator to separate the elements of the array. ...
Printing an Array in PHP To print or echo an array in PHP, you can use the print_r($variable, $return) or var_dump($variable1, $variable2, ...) functions. The print_r() function prints information about the passed variable in human-readable form. The first parameter is the "varia...
echo "Welcome to Java2Blog \n"; $arr = array("Java", "PHP", "Python", "Scala", "JavaScript"); foreach ($arr as $value) { echo "$value \n"; } ?> Output Welcome to Java2Blog Java PHP Python Scala JavaScript That’s all about how to print an array in PHP. Was this post...
Let's take a look at an example to understand how it basically works:ExampleTry this code » <?php $zoo = array("Lion", "Elephant", "Tiger", "Zebra", "Rhino", "Bear"); if(in_array("Elephant", $zoo)){ echo "The elephant was found in the zoo."; } echo ""; if(in_array...
To convert an array to a string in PHP you can use implode($separator, $array), json_encode($array) or serialize($array) functions. The implode() function allows you to concatenate array elements into a single string. To do this, pass an array, and a delimiter to the implode(); the...
In this tutorial, we are going to learn about how to clear or empty an array of values in PHP. Clearing the array To clear an array in PHP…
In this article, we will learn how to convert an array into String using PHP's built in function. Just like the front-end JavaScript, PHP has also, join() method which joins each and every element of the array into a nicely formatted string with a separator. The separator separates the...
feof($csvToRead)) { $csvArray[] = fgetcsv($csvToRead, 1000, ','); } fclose($csvToRead); return $csvArray; } // CSV file to read into an Array $csvFile = 'csv-to-read.csv'; $csvArray = csvToArray($csvFile); echo ''; print_r($csvArray); echo ''; ?> This program set...