Mind blowing SEO improving and Google rank increasing Signature Rotator SEO Tool.

Thread: 

how to create array and how to echo array?

Ads
banner
ivan Offline referral

Posts: 719
Joined: Jul 2013
Reputation: 6

#1
Senior Member
I wanna learn how to create array and then how to echo array?
damponting44 Offline referral

Posts: 537
Joined: Oct 2016
Reputation: 0

#2
Senior Member
In PHP, the array() function is used to create an array:
In PHP, there are three types of arrays:

1. Indexed arrays - Arrays with a numeric index.
2. Associative arrays - Arrays with named keys
3. Multidimensional arrays - Arrays containing one or more arrays.
LinensRange786 Offline referral

Posts: 2
Joined: Nov 2017
Reputation: 0

#3
Junior Member
This is such an informative post. You have a lot of categorically great points. I wish I had this post as a means when I in full swing forum posting..
Victor Dub Offline referral

Posts: 872
Joined: Oct 2013
Reputation: 3

#4
Posting Freak
You can use PHP #Explode function to covert list into an #array:
PHP Code:
$array "1
2
3
4
5"
;
$my_array explode("\n"$array); 

Now you have your values stored in this array: $my_array

To echo array you can use either #printr or #foreach

PHP Code:
foreach($my_array as $vall)
{
echo 
$vall;


You can also use #implode to echo array and comma separate results like so:

PHP Code:
implode(', '$my_array

Keep in mind that for Multidimensional Array implode won't work you need to use foreach.





User(s) browsing this thread: 1 Guest(s)