Dispaly list of pages exclude childe pages

<?php
$output = wp_list_pages('echo=0&depth=1&title_li=<h2>Top Level Pages </h2>' );
if (is_page( )) {
  $page = $post->ID;
  if ($post->post_parent) {
    $page = $post->post_parent;
  }
  $children=wp_list_pages( 'echo=0&child_of=' . $page . '&title_li=' );
  if ($children) {
    $output = wp_list_pages ('echo=0&child_of=' . $page . '&title_li=<h2>Child Pages</h2>');
  }
}
echo $output;
?>

Function to remove HTML form text

function html2text($html)
{
$tags = array (
0 => ‘~<h[123][^>]+>~si’,
1 => ‘~<h[456][^>]+>~si’,
2 => ‘~<table[^>]+>~si’,
3 => ‘~<tr[^>]+>~si’,
4 => ‘~<li[^>]+>~si’,
5 => ‘~<br[^>]+>~si’,
6 => ‘~<p[^>]+>~si’,
7 => ‘~<div[^>]+>~si’,
);
$html = preg_replace($tags,”\n”,$html);
$html = preg_replace(‘~</t(d|h)>\s*<t(d|h)[^>]+>~si’,’ – ‘,$html);
$html = preg_replace(‘~<[^>]+>~s’,”,$html);
// reducing spaces
$html = preg_replace(‘~ +~s’,’ ‘,$html);
$html = preg_replace(‘~^\s+~m’,”,$html);
$html = preg_replace(‘~\s+$~m’,”,$html);
// reducing newlines
$html = preg_replace(‘~\n+~s’,”\n”,$html);
return $html;
}

echo html2text($html);

Posted in PHP