0

Find the last element of an array while using a foreach loop in PHP

[code language=”php”]
$index = 0;
foreach($data as $key=>$val)
{
    // Use $key as an index, or…

    // … manage the index this way..
    echo "Index is $indexn";
    $index++;
}
[/code]

Sandeep Kumar

Sandeep kumar is a web developer and a professinal blogger. He works for latest technologies and write articles what he learn. In ICodeHub he share web languages tutorials and other programming tips and tricks. if you need some help or have some suggestion then mail him at sandeep92pal@gmail.com without any hesitation. He believes in learning and sharing.