WordPressのカスタマイズとプラグイン、CSSテクニック、SEOの話題など。
In: php
19 1月 2010手っ取り早く、ページ内に他のページのヘッダー部分とかメニューの一部とかを表示したい、と思うことが結構あるので、再利用できるように関数化しました。
function ripping_html($source,$start,$end){ $html_source = file_get_contents("$source"); $rip_source = preg_replace('/\n/', ' ', $html_source); $pattern= "/$start(.*)$end/"; preg_match($pattern, $rip_source, $match); echo $match[0]; }
使い方
string ripping_html ( resource $context, string $start , string $end )
例
ripping_html(‘http://blog.dacelo.info/example.html’, ‘‘, ‘
‘);
ここは、SE見習いである私ことdaceloが、日夜習得していくシステム関連の備忘録、phpやWordPressTipsのネタ、あるいはSEOやWebマーケティング関連の雑感を投稿するブログです。 平日は大体毎日投稿しています。土日は休業日です。