$(document).ready(function(){
$(".matchedit").on('input', function postinput(){
var matchvalue = $(this).val(); // this.value
$.ajax({
url: 'matchedit-data.php',
data: { matchvalue: matchvalue },
type: 'post'
}).done(function(responseData) {
// подгружаете контент (responseData) в HTML
}).fail(function() {
console.log('Failed');
});
});
});
function toHtml(array $content) {
$html = '';
foreach ($content as $row) {
if (is_string($row)) {
$html .= $row;
continue;
}
$attrs = '';
if (isset($row['attrs'])) {
foreach ($row['attrs'] as $name => $value) {
if ($row['tag'] === 'img') {
$value = '//telegra.ph' . $value;
}
$attrs .= sprintf(' %s="%s"', $name, $value);
}
}
$children = '';
if (isset($row['children'])) {
$children .= toHtml($row['children']);
}
$html .= sprintf('<%s%s>%s</%s>', $row['tag'], $attrs, $children, $row['tag']);
}
return $html;
}
$content = json_decode(
file_get_contents('https://api.telegra.ph/getPage/Vozmozhnosti-Telegram-03-30?return_content=true'),
true
);
echo toHtml($content['result']['content']);
data-chrome="nofooter noheader"
https:\/\/twitter\.com\/(.+)$
$subject='https://twitter.com/durov';
$regexp='%https:\\/\\/twitter\\.com\\/(.+)$%';
// если любой url подобного рода, то
//$regexp='%[fhtps]{3,5}:\\/\\/[^\\/]+?\\/(.+)$%'
echo $result = preg_replace($regexp, '\\1', $subject);
var subject='https://twitter.com/durov';
var result = subject.replace(/https:\\/\\/twitter\.com\\/(.+)$/g, "\\1");
console.log(result);