Skip to content

Instantly share code, notes, and snippets.

Remove HTML tags

<?php

$html = '<div class="cc">
    Explore the use of simple 
    <a class="keyword_w_elaboration">technologies</a>
    <div class="elaboration" style="text-decoration:none">
 
@odan
odan / splitting-pdf.md
Last active March 25, 2023 11:26
Spliting a PDF file into multiple PDF files

Spliting a PDF file into multiple PDF files

This function extracts all of the pages from a larger PDF file into single-page PDF files.

Installation

composer require setasign/fpdi-fpdf
@odan
odan / remove-namespaces-xml.php
Last active March 29, 2024 09:34
Remove all namespaces from XML in PHP (dirty hack)
<?php
$dom = new DOMDocument();
$dom->preserveWhiteSpace = false;
$dom->formatOutput = true;
$dom->loadXML(file_get_contents(__DIR__ . '/demo.xml'));
$dom = removeAllNamespaces($dom);
$dom->save('demo-out.xml');
@odan
odan / mocking-interface-phpunit.md
Last active March 29, 2023 12:32
Mocking Interfaces with PHPUnit

Mocking Interfaces with PHPUnit

Using the MockBuilder

To mock an interface with PHPUnit we have to pass all methods of the given Interface.

 $reflection = new \ReflectionClass(UserRepositoryInterface::class);

$methods = [];
<?php
use PhpOffice\PhpSpreadsheet\Cell\Coordinate;
use PhpOffice\PhpSpreadsheet\Reader\Xlsx;
/**
* ExcelFileReader.
*/
class ExcelFileReader
{
@odan
odan / aspnet-core-2-ubuntu-setup.md
Last active March 25, 2023 11:26
Installing ASP.NET Core 2.1 on Ubuntu 18.4 Linux
@odan
odan / xmapp-replacing-mariadb-with-mysql.md
Last active June 4, 2023 19:44
XAMPP - Replacing MariaDB with MySQL

XAMPP - Replacing MariaDB with MySQL

This post has been deleted.

@odan
odan / factory.php
Last active August 14, 2017 14:26
Dependency Injection with PHP
<?php
class Configuration
{
private $settings = [];
public function __construct(array $settings)
{
$this->settings = $settings;
}
@odan
odan / rest_quick_reference.md
Last active September 1, 2021 20:06
REST, RESTful API Quick Reference
@odan
odan / php-oracle.md
Last active November 13, 2020 20:03
XAMPP - Oracle Driver Setup (v12)