mrkrstphr / php-gedcom

UNMAINTAINED - A library for reading and writing GEDCOM files in PHP.
MIT License
38 stars 46 forks source link

Array() Array() before every individual #21

Open MattSlone opened 9 years ago

MattSlone commented 9 years ago

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.