php-gedcom icon indicating copy to clipboard operation
php-gedcom copied to clipboard

Array() Array() before every individual

Open MattSlone opened this issue 9 years ago • 0 comments

Hi, great library, it's been a lot of help! I'm not sure if this is where I put questions like this, if not I'll post it somewhere else.

For some reason though, I always have "Array() Array()" before every individual.

Here's my code:


spl_autoload_register(function ($class) {
    $pathToPhpGedcom = __DIR__ . '/plugins/'; // TODO FIXME

    if (!substr(ltrim($class, '\\'), 0, 7) == 'PhpGedcom\\') {
        return;
    }

    $class = str_replace('\\', DIRECTORY_SEPARATOR, $class) . '.php';
    if (file_exists($pathToPhpGedcom . $class)) {
        require_once($pathToPhpGedcom . $class);
    }
});

$parser = new \PhpGedcom\Parser();
$gedcom = $parser->parse('sampleged.ged');

echo "<br /><br />";

foreach ($gedcom->getIndi() as $individual) {
    echo $individual->getId() . ': ' . current($individual->getName())->getSurn() .
        ', ' . current($individual->getName())->getGivn();
}
?>

And here's what I get:

Array ( [0] => Anakin /Skywalker/ ) Array ( [0] => Anakin ) Array ( [0] => Skywalker ) Array ( [0] => Padme /Amidala/ ) Array ( [0] => Padme ) Array ( [0] => Amidala ) Array ( [0] => Luke /Skywalker/ ) Array ( [0] => Luke ) Array ( [0] => Skywalker )

Array ( ) Array ( ) I1: Skywalker, AnakinArray ( ) Array ( ) I2: Amidala, PadmeArray ( ) Array ( ) I3: Skywalker, Luke


Also, is there a solution for removing this info: Array ( [0] => Anakin /Skywalker/ ) Array ( [0] => Anakin ) Array ( [0] => Skywalker ) Array ( [0] => Padme /Amidala/ ) Array ( [0] => Padme ) Array ( [0] => Amidala ) Array ( [0] => Luke /Skywalker/ ) Array ( [0] => Luke ) Array ( [0] => Skywalker )

that appears at the top no matter what I change in the code it seems.

MattSlone avatar May 11 '15 20:05 MattSlone