How to print array values in php using find i value – Indexed array

Google+ Pinterest LinkedIn Tumblr

How to print array values indexing in php using Indexed array

Indexed array is array with a numeric index. Index will Start with ‘0’ and it can be assigned automatically


< ?php

$design = array(‘photoshop’,’flash’,’dreamviewer’,’html5′);

echo $design[0]; //output is photoshop

echo $design[1]; //output is flash


If you know the total number of array values means you can do like this,

For unknown and unlimited array values are present then go to Forloop


< ?php
$var1 = array('one','122','122','122','dfd','dfgdf','dfgdfg','dfgdfg','dfgdfgf','dfgdfg','dfgdfgdf','gfdgdfg','dfgdfgdf','fdg','dfgdf','last');

$total = count($var1); // Use Count(); functions

for($i=0; $i< $total; $i++)
echo "$var1[$i]

To know the array total values use count(); Functions

 2. Count();

This Function is used to fin the count of array key in the array.

3. Associative array()

Associative array is array that use named keys that you assign to them.



$var2 = array('raj'='123','sekar'=>'213','developer'=>'545','desks'=>'345');

echo $var2['raj']; // output is 123
echo $var2['sekar']; // output is 213
echo $var2['developer']; // output is 545
echo $var2['desks']; // output is 345


For more Explanation click here

I'm Rajasekar - Web developer, Freelancer, Blogger and Owner of DeveloperDesks. From India lives in Bahrain. I love to do coding, Creating websites and trying different with code and designs. You Can Hire Me