These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | /** |
||
2 | * NoXMLSpace |
||
3 | * |
||
4 | * @author Thiago Augustus de Oliveira |
||
5 | * @version 1.0.0 |
||
6 | * @copyright MIT Copyright (c) 2015 |
||
7 | */ |
||
8 | final class NoXMLSpace |
||
9 | { |
||
10 | |||
11 | /** |
||
12 | * noSpace |
||
13 | * Remove all spaces in both side of the words in a .xml file |
||
14 | * |
||
15 | * Here is an inline example: |
||
16 | * <code> |
||
17 | * <?php |
||
18 | * $file = simplexml_load_file($_FILES['xml']['tmp_name']); |
||
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
19 | * $xml = noSpace($xml); |
||
20 | * ?> |
||
21 | * </code> |
||
22 | * |
||
23 | * @param xml |
||
24 | * @return xml |
||
25 | * @access public |
||
26 | */ |
||
27 | public static function noSpace( $xml = null ) |
||
28 | { |
||
29 | |||
30 | if ( empty( $xml ) || is_null( $xml ) ) return false; |
||
31 | |||
32 | foreach ( $xml as $key => $value ) { |
||
33 | if ( sizeof( $value ) > 1 ) { |
||
34 | noSpace( $value ); // Get next node |
||
35 | } else { |
||
36 | $xml->$key = trim( $value ); |
||
37 | } |
||
38 | } |
||
39 | return $xml; |
||
40 | } |
||
41 | |||
42 | } |
||
43 | |||
44 | // $xml = simplexml_load_file( $xml_file ); |
||
45 | // Example: var_dump( '<pre>', NoXMLSpace::noSpace($xml) ); |
||
46 |