I have an array built from a log file and I want to create a new array containing only the player names.
$list[2] is the location of the player names
if(preg_match_all('/^(.*?) Player "(.*)" (.*) /m', $open, $list))
{
foreach($list[2] as $name)
{
if(!in_array($name,$players))
{
$players[] = ["Player"=>$name];
}
}
}
var_dump($players);
Its adding the player names to the array however it is adding even if an entry exists with the name as a value.
** Answer ** Was resolved following suggested answer by using
$gt = array_unique($list[2]);
foreach($gt as $name)
{
$players[] = ["Player"=>$name];
}