Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6888849
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:04:48+00:00 2026-05-27T06:04:48+00:00

hello everybody i have a question regarding strip_tags function. i have an html document

  • 0

hello everybody i have a question regarding strip_tags function.
i have an html document like that.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<p>er</p>
</body>
</html>

and this php script

<?php
$file = "ht.html";
$fp = fopen($file, "r");
$data = fread($fp, filesize($file));
fclose($fp);
$output = str_replace("\t|\t", "|", $data);
$outputline = explode("\n", $output);
$lexeisline=count($outputline);

for ($i = 0; $i < $lexeisline; $i++){
    $outputline[$i]=strip_tags($outputline[$i]);
      if (empty($outputline[$i])){
          unset($outputline[$i]);
}
}
$outputline = array_values($outputline);
$lexeisline=count($outputline);
echo "<p>";
for ($i = 0; $i < $lexeisline; $i++){
echo ($outputline[$i])."<br />";
}
echo "</p>";
?>

the problem is that it does not unset the empty vars(which are returned from the strip_tags) and echos something like this. does the following means that it echos empty strings?
any opinion or help will be very appreciated. Thanx in advance

<p>
<br />
<br />
<br />
<br />Untitled Document
<br />
<br />
<br />er
<br />
<br /></p>

@phpmeh

 Array
    (
        [0] => 
        [1] => 
        [2] => 
        [3] => 
        [4] => Untitled Document
        [5] => 
        [6] => 
        [7] => er
        [8] => 
    )
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T06:04:49+00:00Added an answer on May 27, 2026 at 6:04 am

    This code seems incredibly baroque for what you are doing. Does the following code do what you need?

    $lines = file('ht.html');
    $lines = array_map('strip_tags', $lines);
    $lines = array_map('trim', $lines);
    $lines = array_filter($lines);
    
    echo "<p>\n", implode("<br />\n", $lines), "\n</p>";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello everybody, I have a small code in PHP that I would like to
Hello everybody I have a question: I have a array String[] parte and I
Hello everybody! I have a SQL (see above) and i would like to know
My string contain a lot of HTML entities, like this &#x22;Hello&nbsp;&lt;everybody&gt;&nbsp;there&#x22; And I want
Hello everybody Well my question is about sql commands... If I have 2 tables
Hello everybody and sorry for the rather confusing question-title. I have a Hibernate Class
Note: This question is posted here hello everybody, I have a predefind list of
Hello everybody I have a LINQ declaration like this : var query = from
Note: Using Monotouch and doing all the UI Programatically. Hello everybody, I have a
Hello everybody I have this string: [JOLLY BLU at STAY SHIP, Voy: 0275/11] How

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.