Tuesday, November 10, 2015

PHP array explode count number of element

Small example:

$itemList = explode(",", $itemList);
echo count($itemList);                              
       for($i=0;$i<count($itemList);$i++)
Real code:
<?php
$imgURL = "../users/awmayhall/images/andrew1.jpg:../users/awmayhall/images/andrew2.jpg:";
$delimiter=":";
$itemList = array();
$itemList = explode($delimiter, $imgURL);
foreach($itemList as $item)
{
  echo"<img src='".$item."' longdesc='".$item."'/>";
}
?>

No comments:

Post a Comment