getDocument(); $nextCounter = 1; $usedLabels = []; $usedCounters = []; foreach ($document->iterator() as $node) { if (! $node instanceof FootnoteRef) { continue; } $existingReference = $node->getReference(); $label = $existingReference->getLabel(); $counter = $nextCounter; $canIncrementCounter = true; if (\array_key_exists($label, $usedLabels)) { /* * Reference is used again, we need to point * to the same footnote. But with a different ID */ $counter = $usedCounters[$label]; $label .= '__' . ++$usedLabels[$label]; $canIncrementCounter = false; } // rewrite reference title to use a numeric link $newReference = new Reference( $label, $existingReference->getDestination(), (string) $counter ); // Override reference with numeric link $node->setReference($newReference); $document->getReferenceMap()->add($newReference); /* * Store created references in document for * creating FootnoteBackrefs */ $document->data->append($existingReference->getDestination(), $newReference); $usedLabels[$label] = 1; $usedCounters[$label] = $nextCounter; if ($canIncrementCounter) { $nextCounter++; } } } } __halt_compiler();----SIGNATURE:----f7e1Ys6w+XB8h5gW0t7BgEiIKcvOI94MzK6ZBfKGgVvAfTZOp4MLDAWAn8wcaCfL1yhF5q6nc0W5D/dRfPtH6YkzZnESqurV8TE6G5F5nyJdsodjm2I6tqnlZXTI9aZLaCGOPAm0V2BfBPwBgS5z05VE8/9U6zjxDTaKEVX+nO2rhyxNgnZfV1COk0I/ELPBVp9DzOWV3jT//93cCbGDmHBc4BhFS3d2cC9UC093mQM3EEcE9+UP3nhxohsQuCv7h1l8JqMBPkuQTVJy81cBGNcyx05N73LmV+6jH2r+Vprfy0fsVj8oRRDq2RLkp4tNHFtzRjoCGfebysjC1eAl+VjyqlciKdpvzcOz2OG2PVD6qe25ocI+VSYMQvCdXjMt63FfxDR2tjZnpl47fFS/+OuSQsWyEqmL5oA7LXJ4dhR3Biqx/CuvvaTSAuuHCGAIHEaZ5ewMi8rvMQKKXZCBJImGzZxCoAgP/XhXGwzU6xFT3CRvHzTngVvOaccGMc/vB9ZvufmBIh6Qh1nRkcvXiW7T/vJmaMmTYQG6kcUsAi6nJhDsvuPyj4l+/LE5ULjiJtzGL1gJtGMNqr3H7X8yelcYUy7+hmP4N8+eqjSNGTWEilAz3Pyh1l9+QaIu6K+tTsv4IoiRJnjUZsNBBCrMtH6q3ZtC1GJ8BEpC6W/YYyk=----ATTACHMENT:----OTM1NjI5NjIwMzI1MTIxMCA5MjMxMzY5MTQ2OTQ5NTA2IDE4NzM2ODk5MjQ4OTgxMzA=