You appear to be a bot. Output may be restricted
Description
Perform replacements of paired markup stringsNotes:
- This logic requires the paired replacements to appear on the same line.
- It should cater for nested pairs.
- It should ensure that the pairs don't overlap.
Usage
$string = paired_replacements( $before, $after, $beforetag, $aftertag, $line );
Parameters
- $before
- ( string ) required – the start of the markdown string
- $after
- ( string ) required – the end of the markdown string
- $beforetag
- ( string ) required – the string to replace before
- $aftertag
- ( string ) required – the string to replace after
- $line
- ( string ) required – the string to be searched
Returns
string the updated stringSource
File name: oik-shortcodes/shortcodes/oik-api-importer.phpLines:
1 to 14 of 14
function paired_replacements( $before, $after, $beforetag, $aftertag, $line ) { $spos = strpos( $line, $before ); while ( $spos !== false ) { $epos = strpos( $line, $after ); if ( $epos > ( $spos + strlen( $before ) ) ) { $line = replace_at( $epos, $after, $aftertag, $line ); $line = replace_at( $spos, $before, $beforetag, $line ); $spos = strpos( $line, $before ); } else { $spos = false; } } return( $line ); }View on GitHub