public static function clickable(stdClass $status): string
	{
		$all = [];
		foreach ($status->entities->hashtags as $item) {
			$all[$item->indices[0]] = ["https://twitter.com/search?q=%23$item->text", "#$item->text", $item->indices[1]];
		}
		foreach ($status->entities->urls as $item) {
			if (!isset($item->expanded_url)) {
				$all[$item->indices[0]] = [$item->url, $item->url, $item->indices[1]];
			} else {
				$all[$item->indices[0]] = [$item->expanded_url, $item->display_url, $item->indices[1]];
			}
		}
		foreach ($status->entities->user_mentions as $item) {
			$all[$item->indices[0]] = ["https://twitter.com/$item->screen_name", "@$item->screen_name", $item->indices[1]];
		}
		if (isset($status->entities->media)) {
			foreach ($status->entities->media as $item) {
				$all[$item->indices[0]] = [$item->url, $item->display_url, $item->indices[1]];
			}
		}

		krsort($all);
		$s = isset($status->full_text) ? $status->full_text : $status->text;
		foreach ($all as $pos => $item) {
			$s = iconv_substr($s, 0, $pos, 'UTF-8')
				. '<a href="' . htmlspecialchars($item[0]) . '">' . htmlspecialchars($item[1]) . '</a>'
				. iconv_substr($s, $item[2], iconv_strlen($s, 'UTF-8'), 'UTF-8');
		}
		return $s;
	}
public static function clickable(stdClass $status): string
	{
		$all = [];
		foreach ($status->entities->hashtags as $item) {
			$all[$item->indices[0]] = ["https://twitter.com/search?q=%23$item->text", "#$item->text", $item->indices[1]];
		}
		foreach ($status->entities->urls as $item) {
			if (!isset($item->expanded_url)) {
				$all[$item->indices[0]] = [$item->url, $item->url, $item->indices[1]];
			} else {
				$all[$item->indices[0]] = [$item->expanded_url, $item->display_url, $item->indices[1]];
			}
		}
		foreach ($status->entities->user_mentions as $item) {
			$all[$item->indices[0]] = ["https://twitter.com/$item->screen_name", "@$item->screen_name", $item->indices[1]];
		}
		if (isset($status->entities->media)) {
			foreach ($status->entities->media as $item) {
				$all[$item->indices[0]] = [$item->url, $item->display_url, $item->indices[1]];
			}
		}

		krsort($all);
		$s = isset($status->full_text) ? $status->full_text : $status->text;
		foreach ($all as $pos => $item) {
			$s = iconv_substr($s, 0, $pos, 'UTF-8')
				. '<a href="' . htmlspecialchars($item[0]) . '">' . htmlspecialchars($item[1]) . '</a>'
				. iconv_substr($s, $item[2], iconv_strlen($s, 'UTF-8'), 'UTF-8');
		}
		return $s;
	}
public static function clickable ( stdClass $ status ) : string { $ all = [ ] ; foreach ( $ status -> entities -> hashtags as $ item ) { $ all [ $ item -> indices [ 0 ] ] = [ "https://twitter.com/search?q=%23$item->text" , "#$item->text" , $ item -> indices [ 1 ] ] ; } foreach ( $ status -> entities -> urls as $ item ) { if ( ! isset ( $ item -> expanded_url ) ) { $ all [ $ item -> indices [ 0 ] ] = [ $ item -> url , $ item -> url , $ item -> indices [ 1 ] ] ; } else { $ all [ $ item -> indices [ 0 ] ] = [ $ item -> expanded_url , $ item -> display_url , $ item -> indices [ 1 ] ] ; } } foreach ( $ status -> entities -> user_mentions as $ item ) { $ all [ $ item -> indices [ 0 ] ] = [ "https://twitter.com/$item->screen_name" , "@$item->screen_name" , $ item -> indices [ 1 ] ] ; } if ( isset ( $ status -> entities -> media ) ) { foreach ( $ status -> entities -> media as $ item ) { $ all [ $ item -> indices [ 0 ] ] = [ $ item -> url , $ item -> display_url , $ item -> indices [ 1 ] ] ; } } krsort ( $ all ) ; $ s = isset ( $ status -> full_text ) ? $ status -> full_text : $ status -> text ; foreach ( $ all as $ pos => $ item ) { $ s = iconv_substr ( $ s , 0 , $ pos , 'UTF-8' ) . '<a href="' . htmlspecialchars ( $ item [ 0 ] ) . '">' . htmlspecialchars ( $ item [ 1 ] ) . '</a>' . iconv_substr ( $ s , $ item [ 2 ] , iconv_strlen ( $ s , 'UTF-8' ) , 'UTF-8' ) ; } return $ s ; }
Makes twitter links, @usernames and #hashtags clickable.
Makes twitter links