I have data like this : 99||null|Group1@alex~bryan~john#Group2@sarah~jeny~yeni
This data should be parsed and displayed like this :
alex
bryan
sarah
jeny
i made function but not work yet. now, this function only display like this:
sarah
jeny
this is because there are 2 looping (for). First for listing group and second for listing its people.
Any idea to solve this problem?? Thanks..
here is my code:
<?php
function listContacts() {
$data="99||null|Group1@alex~bryan#Group2@sarah~jeny";
$get=str_replace("||","|",$data);
$arrData= explode("|", $get);
$parseGroup = explode("#",$arrData[2]);
$countUser=count($parseGroup);
for ($i=0; $i<$countUser; $i++)
{
$repl=strpos($parseGroup[$i],"@");
$parseList = substr($parseGroup[$i],$repl+1);
$explList = explode("~",$parseList);
$countExplList=count($explList);
for ($j=0; $j < $countExplList; $j++)
{
$Val[$j][0] = $explList[$j];
}
}
return $Val;
}
/// RUN FUNCTION
$list=listContacts();
$countList=count($list);
echo $countList."<br>";
for ($i = 0; $i < $countList; $i++)
{
echo $list[$i][0]."<br>";
}
?>