Created
November 27, 2018 11:51
-
-
Save campusboy87/dbc2cb57e306bb18623740a2cdf658c2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $data = wp_remote_get( 'https://www.tvasites.com/cmswebparts/insite3/api/exporttowordpress.aspx' ); | |
| $data = wp_remote_retrieve_body( $data ); | |
| $output = []; | |
| if ( preg_match_all( '/{([^}]*)}/', $data, $matches ) ) { | |
| foreach ( $matches[1] as $item ) { | |
| $lines = preg_split( '/\\r\\n?|\\n/', $item, null, PREG_SPLIT_NO_EMPTY ); | |
| if ( is_array( $lines ) ) { | |
| $lines = array_map( function ( $item ) { | |
| $line = explode( ': ', $item ); | |
| return '"' . $line[0] . '": "' . trim( $line[1], "'," ) . '",'; | |
| }, $lines ); | |
| $output[] = json_decode( '{' . rtrim( join( '', $lines ), ',' ) . '}' ); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Нубокод