Skip to content

Instantly share code, notes, and snippets.

@campusboy87
Created November 27, 2018 11:51
Show Gist options
  • Select an option

  • Save campusboy87/dbc2cb57e306bb18623740a2cdf658c2 to your computer and use it in GitHub Desktop.

Select an option

Save campusboy87/dbc2cb57e306bb18623740a2cdf658c2 to your computer and use it in GitHub Desktop.
<?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 ), ',' ) . '}' );
}
}
}
@mihdan

mihdan commented Nov 27, 2018

Copy link
Copy Markdown

Нубокод

@campusboy87

Copy link
Copy Markdown
Author

Нубокод

Ожидаем профикод

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment