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:----D6XoqCaDDA625hnmpY78IXDTz+yxddLARVDRINX6kOtsfZtNtyZwvmDcfshjl6KcGiPE5m/YqfFwB741EYJ98sRDGZgpZUWW2NNFh4FyYQvgnQ2R7H0OejAD+PH9B+UkQHHFbXpJ+uBYZ0wqD+nyf5qP7xDWiBO03C8nZk/mSA2h86X1risCAcctAfnYL1rID7yoGS4Eeb1WRa2QXlcMCxj5oPTIfgcjaE+aTA/ok6GWxIN+hJXT75YHqGmfTO0W6TzVy5pcBAM6Qio6T6AwsfWrynYw0P53h07U57pKbPwbVa555G2yrt/CLF7K/wJlTV0R1YJme6UQJRDj4b5Hp6yzfpRAzDgbNwwDtvU2OnaVGWIqBlxzKZ5PRHcQe4nitn5G7S/Px/I7cIrs5EkjG/27937QhQ+J8nUvqp28pv5snXsH1I81PCveMpPKiEpm0s0WzdEsnfyK/ae7OqBqCp0gHnVImdT7n7g8pisoXfEyyACjSftxfjvxMo7zYdgVGEl/umDL5QSg6zFQFVLP2p5m6Ix9DxVYtwrp6zOGF0ZokR6nAyG3K9KDWDVmm0Qi/PoZp9BuUhCyf60kcbEH1s7VqKWM1wTPJqBHStSrsb+8jjh03lQIg9z/inNSqzKx/iDPhzcGCErqX1Xo2thdOua5U+yfsYjXPKCUWLyf6As=----ATTACHMENT:----NjMzNTEzMDI3NTgwMTc5OSAyMDc1ODIwMjU2NTQ5MDE1IDU4MDE1NjI3MzAxOTY1ODc=