All New

user:thomas gists created by user

title:mygist gists with given title

filename:myfile.txt gists having files with given name

extension:yml gists having files with given extension

language:go gists having files with given language

topic:homelab gists with given topic

Login


All New Login

All gists matching topic PHP

Recently created
Least recently created
Recently updated
Least recently updated
portalzine's Avatar

portalzine / Extract text between two tags (domDocument)

0 likes
0 forks
1 files
Last active 7 months ago
Coding PHP Solutions domDocument
1 $tag = "p";
2 $html ="I am here!";
3 $dom = new domDocument('1.0', 'utf-8');
4 $dom->loadHTML($html);
5 $dom->preserveWhiteSpace = false;
6
7 $findTag = $dom->getElementsByTagName($tag);
8
9 echo $findTag->item(0)->nodeValue;
portalzine's Avatar

portalzine / Syntax Highlighting Class

0 likes
0 forks
2 files
Last active 7 months ago
PHP Solutions
1 class SyntaxHighlight {
2
3 static $tokens = array();// This array will be filled from the regexp-callback
4 public static function process($s) {
5 $s = htmlspecialchars($s);
6 // Workaround for escaped backslashes
7 $s = str_replace('\\\\','\\\\<e>', $s);
8 $regexp = array(
9 // Punctuations
10 '/([\-\!\%\^\*\(\)\+\|\~\=\`\{\}\[\]\:\"\'<>\?\,\.\/]+)/'
Newer Older

Powered by Opengist ⋅ Load: 89ms⋅

English
Čeština Deutsch English Español Français Magyar Italiano 日本語 Polski Português Русский Türkçe Українська 中文 繁體中文
⋅ Data Privacy