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:----OcHYea8blyfiiiGzaS1R63Yh3P1fO0QAlVg/b+duRfHm1aNqDa2DyTfbJuJgVwjj8QclY3ctRWmOODNUQB3xy1SRCMJ0J86G7Yy1gCjbLg5SF3rcm9/xKbobvE8z7fxUVvQta9ChXzT6RCkGVOX68H80js08U1Smo6Dp4SDnSxqfE61Wvc7L+kOz6J+BGtmYUqV28IjBZXF+ycASyPST0+iX/isrnoasNiWMbfY4KJCtfZfqe7miPgYYt1P2/mfx0FVMOk103Y0oyoh3W7al//hhetr0bvIvaykLJZ4Qemx4NNusqGOY7P6qugjfJrxBt3QqP6lKaFtxmpfV6cXJI9iNMI8YQXBIffoX88JNAnlEHdHuu2TE3hfo3M8jENiS5YVNyZDO8X5M3+P0KFzuPN9ssN6sVpP3UjWhu+th8ZL98OHU23sHb7uFZY/AJXlWkEDXYn3A9jztxI3PYWS35Gb0RW8ZLb+uFTwaKmcJSO9JRmyUosD6iYrwpP4xT6FvoJWHPnDNBypkj6OiFrik+DNH1/Iaj2+1W1ZyRsZsBGvqxwfxfAmFvI84RnkC2i2mvTsNdr3l8hepwgRly8s/ImWFBjvhYIoyO/A72aqjVpcgzhi0bK2OOy0Knz2br03AadqqNXFZbqBZ+vu52Zj5X1YkWxLai/OTAMVf78XDuOg=----ATTACHMENT:----OTM0NjMwNTU1MzY5MjQyNSA0MTE2MTYxMzE1MDYzODU0IDU4ODQ1OTk0MTY3MDU1MTg=