Template:TitleParts/Splice/2
We want this function to work EXACTLY like PHP's array_splice does. An index of 0 will represent the first element of the array. Given: A/B/C/D we want 3,1,E to return A/B/C/E Given: A/B/C/D we want 3,2,E to return A/B/C/E Given: A/B/C/D we want 2,1,E to return A/B/E/D Given: A/B/C/D we want 2,2,E to return A/B/E Given: A/B/C/D we want 4,1,E to return A/B/C/D/E Given: A/B/C/D we want 5,1,E to return A/B/C/D/E Given: A/B/C/D we want 2,1,E to return A/B/E/D Given: A/B/C/D we want 1,1,E to return A/E/C/D Given: A/B/C/D we want 0,1,E to return E/B/C/D Given: A/B/C/D we want 0,0,E to return E/A/B/C/D Given: A/B/C/D we want 0,5,E to return E Given: A/B/C/D we want 5,0,E to return A/B/C/D/E So basically the first number is the number of elements to return -->{{#titleparts: {{{1|}}} | {{#ifexpr: {{{3|0}}} = 0|-99|{{{3|0}}}}} | 1 }}<!-- -->{{#ifeq: {{{5|a}}} | {{{5|b}}} | {{#ifexpr: {{{3|0}}} > 0 | /{{{5|}}} | {{{5|}}} }}|}}<!-- -->{{#ifexpr: ({{{3|0}}}+{{{4|0}}}) < ({{{2|0}}})|{{#ifexpr: {{{3|0}}} > 0| / |{{#ifeq: {{{5|a}}} | {{{5|b}}} | / |<!--empty-->|}}}}|}}<!-- -->{{#titleparts: {{{1|}}} | 0 | {{#expr:{{{3|0}}} + {{{4|0}}} + 1 }}}}<!--
-->This is a helper template that is required by Template:TitleParts/Splice/1.
It takes 5 parameters: array, sizeof(array), spliceOffset, spliceLength, replaceArray
The 5th parameter is optional. SpliceOffset and spliceLength MUST be 0 or greater for them to work properly.
Example
{{Template:TitleParts/Splice/2|A/B/C/D|4|3|1|E}} → A/B/C/E |
{{Template:TitleParts/Splice/2|A/B/C/D|4|4|1|E}} → A/B/C/D/E |
{{Template:TitleParts/Splice/2|A/B/C/D|4|5|1|E}} → A/B/C/D/E |
{{Template:TitleParts/Splice/2|A/B/C/D|4|2|1|E}} → A/B/E/D |
{{Template:TitleParts/Splice/2|A/B/C/D|4|1|1|E}} → A/E/C/D |
{{Template:TitleParts/Splice/2|A/B/C/D|4|0|1|E}} → E/B/C/D |
{{Template:TitleParts/Splice/2|A/B/C/D|4|0|0|E}} → E/A/B/C/D |
{{Template:TitleParts/Splice/2|A/B/C/D|4|0|5|E}} → E |
{{Template:TitleParts/Splice/2|A/B/C/D|4|5|0|E}} → A/B/C/D/E |