Search
 
SCRIPT & CODE EXAMPLE
 

PHP

remove html tags from string php

<?php
	echo strip_tags("Hello <b>world!</b>");
Comment

php remove html tags

<?php
$text = '<p>Test paragraph.</p><!-- Comment --> <a href="#fragment">Other text</a>';
echo strip_tags($text);
//Test paragraph. Other text

// Allow <p> and <a>
echo strip_tags($text, '<p><a>');
//<p>Test paragraph.</p> <a href="#fragment">Other text</a>
// as of PHP 7.4.0 the line above can be written as:
// echo strip_tags($text, ['p', 'a']);
?>

Comment

hmtl remove tag php

<?php
function strip_tags_content($text, $tags = '', $invert = FALSE) {

  preg_match_all('/<(.+?)[s]*/?[s]*>/si', trim($tags), $tags);
  $tags = array_unique($tags[1]);
   
  if(is_array($tags) AND count($tags) > 0) {
    if($invert == FALSE) {
      return preg_replace('@<(?!(?:'. implode('|', $tags) .'))(w+).*?>.*?</1>@si', '', $text);
    }
    else {
      return preg_replace('@<('. implode('|', $tags) .').*?>.*?</1>@si', '', $text);
    }
  }
  elseif($invert == FALSE) {
    return preg_replace('@<(w+).*?>.*?</1>@si', '', $text);
  }
  return $text;
}
?>
Comment

php remove html tag

<?php
$str = "<h1>Hello WorldÆØÅ!</h1>";
# Remove all HTML tags and all characters with ASCII value > 127, from a string:
$newstr = filter_var($str, FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_HIGH);
echo $newstr;
# Result: Hello World!
Comment

PREVIOUS NEXT
Code Example
Php :: laravel createmany example 
Php :: aapanel ubuntu 20.04 
Php :: unlink is a directory laravel 
Php :: laravel-medialibrary packagist 
Php :: password validation rules laravel 
Php :: how to read data from serial port in php 
Php :: delete file in php 
Php :: php erase element from array 
Php :: php How do you remove an array element in a foreach loop? 
Php :: php hash 
Php :: Associative array in php 
Php :: remove item in an array php 
Php :: php redirect seconds 
Php :: how to remove Website field from comments 
Php :: trim array in map php 
Php :: show comma separated numbers in php 
Php :: laravel checkbox checked 
Php :: infinite cookie good php ? 
Php :: upload_max_filesize in wordpress 
Php :: update role spatie 
Php :: add access-control-allow-origin header laravel 
Php :: php ofreach 
Php :: Class "AppHttpControllersAdminController" not found in laravel 8 
Php :: array_key_exists 
Php :: get csv file from server folder in PHP 
Php :: php do not refresh page after submit post 
Php :: PHP MySQL Delete Data 
Php :: what is the difference between static and dynamic websites? 
Php :: laravel natural sort 
Php :: change arabic number to english php 
ADD CONTENT
Topic
Content
Source link
Name
1+9 =