123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- <?php
- defined('BASEPATH') OR exit('No direct script access allowed');
- if ( ! function_exists('xml_convert'))
- {
-
- function xml_convert($str, $protect_all = FALSE)
- {
- $temp = '__TEMP_AMPERSANDS__';
-
-
- $str = preg_replace('/&#(\d+);/', $temp.'\\1;', $str);
- if ($protect_all === TRUE)
- {
- $str = preg_replace('/&(\w+);/', $temp.'\\1;', $str);
- }
- $str = str_replace(
- array('&', '<', '>', '"', "'", '-'),
- array('&', '<', '>', '"', ''', '-'),
- $str
- );
-
- $str = preg_replace('/'.$temp.'(\d+);/', '&#\\1;', $str);
- if ($protect_all === TRUE)
- {
- return preg_replace('/'.$temp.'(\w+);/', '&\\1;', $str);
- }
- return $str;
- }
- }
|