<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	
	xmlns:georss="http://www.georss.org/georss"
	xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#"
	>

<channel>
	<title>PHP &#8211; MaxVergelli.com</title>
	<atom:link href="https://www.maxvergelli.com/category/programming/php/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.maxvergelli.com</link>
	<description>sourcecode repository</description>
	<lastBuildDate>Tue, 14 Apr 2020 17:58:15 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	

<image>
	<url>https://i2.wp.com/www.maxvergelli.com/wp-content/uploads/2020/04/wp-1586823685141.png?fit=32%2C32&#038;ssl=1</url>
	<title>PHP &#8211; MaxVergelli.com</title>
	<link>https://www.maxvergelli.com</link>
	<width>32</width>
	<height>32</height>
</image> 
<site xmlns="com-wordpress:feed-additions:1">34603511</site>	<item>
		<title>Javascript equivalent to PHP __construct</title>
		<link>https://www.maxvergelli.com/javascript-equivalent-to-php-__construct/</link>
					<comments>https://www.maxvergelli.com/javascript-equivalent-to-php-__construct/#respond</comments>
		
		<dc:creator><![CDATA[Max]]></dc:creator>
		<pubDate>Thu, 16 Apr 2020 17:36:00 +0000</pubDate>
				<category><![CDATA[Design]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[class]]></category>
		<category><![CDATA[class-constructor]]></category>
		<category><![CDATA[construct]]></category>
		<category><![CDATA[constructor]]></category>
		<category><![CDATA[constructor-function]]></category>
		<category><![CDATA[constructor-method]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[javascript-class]]></category>
		<category><![CDATA[javascript-construct]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[parameters]]></category>
		<category><![CDATA[php-like]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[scripting]]></category>
		<guid isPermaLink="false">https://www.maxvergelli.com/?p=245</guid>

					<description><![CDATA[Constructor method in Javascript class equivalent to PHP, how to run a function in Javascript whenever the object is instantiated.]]></description>
										<content:encoded><![CDATA[
<p>The <code>constructor</code> method is a special method for creating and initializing an object created within a <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/class"><code>class</code></a>. In other words, it&#8217;s a function that runs automatically whenever the object is instantiated.</p>



<p><strong>Using the <code>constructor</code> method</strong></p>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;mode&quot;:&quot;javascript&quot;,&quot;mime&quot;:&quot;text/javascript&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:true,&quot;lineWrapping&quot;:true,&quot;readOnly&quot;:true,&quot;language&quot;:&quot;JavaScript&quot;,&quot;modeName&quot;:&quot;js&quot;}">class Person {

  constructor(name) {
    this.name = name;
  }

  introduce() {
    console.log(`Hello, my name is ${this.name}`);
  }

}

const otto = new Person('Otto');

otto.introduce();</pre></div>



<p>If you don&#8217;t provide your own constructor, then a default constructor will be supplied for you. If your class is a base class, the default constructor is empty:</p>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;mode&quot;:&quot;javascript&quot;,&quot;mime&quot;:&quot;text/javascript&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:true,&quot;lineWrapping&quot;:true,&quot;readOnly&quot;:true,&quot;language&quot;:&quot;JavaScript&quot;,&quot;modeName&quot;:&quot;js&quot;}">constructor() {}</pre></div>



<p>If your class is a derived class, the default constructor calls the parent constructor, passing along any arguments that were provided:</p>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;mode&quot;:&quot;javascript&quot;,&quot;mime&quot;:&quot;text/javascript&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:true,&quot;lineWrapping&quot;:true,&quot;readOnly&quot;:true,&quot;language&quot;:&quot;JavaScript&quot;,&quot;modeName&quot;:&quot;js&quot;}">constructor(...args) {
  super(...args);
}</pre></div>



<p>Just as a reminder: the <strong>super</strong> keyword is used to access and call functions on an object&#8217;s parent (more information here <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/super" class="aioseop-link">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/super</a>)</p>



<p>Look at these other resources on <strong>Javascript constructor</strong>:</p>



<p><a href="https://stackoverflow.com/questions/61213185/javascript-equivalent-to-php-construct">https://stackoverflow.com/questions/61213185/javascript-equivalent-to-php-construct</a></p>



<p><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes/constructor">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes/constructor</a></p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.maxvergelli.com/javascript-equivalent-to-php-__construct/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">245</post-id>	</item>
		<item>
		<title>How to parse and process HTML/XML in PHP</title>
		<link>https://www.maxvergelli.com/how-to-parse-and-process-html-xml-in-php/</link>
					<comments>https://www.maxvergelli.com/how-to-parse-and-process-html-xml-in-php/#respond</comments>
		
		<dc:creator><![CDATA[Max]]></dc:creator>
		<pubDate>Wed, 15 Apr 2020 16:44:00 +0000</pubDate>
				<category><![CDATA[HTML]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[String Manipulation Algorithms]]></category>
		<category><![CDATA[XML]]></category>
		<category><![CDATA[document]]></category>
		<category><![CDATA[DOM]]></category>
		<category><![CDATA[find-html]]></category>
		<category><![CDATA[grabbing]]></category>
		<category><![CDATA[html-manipulation]]></category>
		<category><![CDATA[html-parser]]></category>
		<category><![CDATA[libxml]]></category>
		<category><![CDATA[parse]]></category>
		<category><![CDATA[parser]]></category>
		<category><![CDATA[parsing]]></category>
		<category><![CDATA[parsing-html]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[php-class]]></category>
		<category><![CDATA[php-extension]]></category>
		<category><![CDATA[php-query]]></category>
		<category><![CDATA[php5]]></category>
		<category><![CDATA[php7]]></category>
		<category><![CDATA[query-path]]></category>
		<category><![CDATA[simple-html-dom]]></category>
		<category><![CDATA[simple-xml]]></category>
		<category><![CDATA[xml-parser]]></category>
		<category><![CDATA[xml-reader]]></category>
		<guid isPermaLink="false">https://www.maxvergelli.com/?p=239</guid>

					<description><![CDATA[Simple HTML DOM is a great open-source parser: simplehtmldom.sourceforge It treats DOM elements in an object-oriented way, and the new iteration has a lot of coverage for non-compliant code. There are also some great functions like you&#8217;d see in JavaScript, &#8230; <a class="kt-excerpt-readmore" href="https://www.maxvergelli.com/how-to-parse-and-process-html-xml-in-php/" aria-label="How to parse and process HTML/XML in PHP">Read More</a>]]></description>
										<content:encoded><![CDATA[
<p>Simple HTML DOM is a great open-source parser:</p>



<p><a href="http://simplehtmldom.sourceforge.net/">simplehtmldom.sourceforge</a></p>



<p>It treats DOM elements in an object-oriented way, and the new iteration has a lot of coverage for non-compliant code. There are also some great functions like you&#8217;d see in JavaScript, such as the &#8220;find&#8221; function, which will return all instances of elements of that tag name.</p>



<p>I&#8217;ve used this in a number of tools, testing it on many different types of web pages, and I think it works great.</p>



<p>These are the main features:</p>



<ul><li>HTML DOM parser written in PHP 5+ that lets you manipulate HTML in a very easy way</li><li>Require PHP 5+</li><li>Supports invalid HTML</li><li>Find tags on an HTML page with selectors just like jQuery</li><li>Extract contents from HTML in a single line</li></ul>



<p><strong>How to get HTML elements:</strong></p>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;mode&quot;:&quot;php&quot;,&quot;mime&quot;:&quot;text/x-php&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:true,&quot;lineWrapping&quot;:true,&quot;readOnly&quot;:true,&quot;language&quot;:&quot;PHP&quot;,&quot;modeName&quot;:&quot;php&quot;}">// Create DOM from URL or file
$html = file_get_html('http://www.example.com/');

// Find all images
foreach($html-&gt;find('img') as $element)
       echo $element-&gt;src . '&lt;br&gt;';

// Find all links
foreach($html-&gt;find('a') as $element)
       echo $element-&gt;href . '&lt;br&gt;';</pre></div>



<p><strong>How to modify HTML elements:</strong></p>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;mode&quot;:&quot;php&quot;,&quot;mime&quot;:&quot;text/x-php&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:true,&quot;lineWrapping&quot;:true,&quot;readOnly&quot;:true,&quot;language&quot;:&quot;PHP&quot;,&quot;modeName&quot;:&quot;php&quot;}">// Create DOM from string
$html = str_get_html('&lt;div id=&quot;hello&quot;&gt;Hello&lt;/div&gt;&lt;div id=&quot;world&quot;&gt;World&lt;/div&gt;');

$html-&gt;find('div', 1)-&gt;class = 'bar';

$html-&gt;find('div[id=hello]', 0)-&gt;innertext = 'foo';

echo $html;</pre></div>



<p><strong>Extract content from HTML:</strong></p>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;mode&quot;:&quot;php&quot;,&quot;mime&quot;:&quot;text/x-php&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:true,&quot;lineWrapping&quot;:true,&quot;readOnly&quot;:true,&quot;language&quot;:&quot;PHP&quot;,&quot;modeName&quot;:&quot;php&quot;}">// Dump contents (without tags) from HTML
echo file_get_html('http://www.google.com/')-&gt;plaintext;</pre></div>



<p><strong>Scraping Slashdot:</strong></p>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;mode&quot;:&quot;php&quot;,&quot;mime&quot;:&quot;text/x-php&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:true,&quot;lineWrapping&quot;:true,&quot;readOnly&quot;:true,&quot;language&quot;:&quot;PHP&quot;,&quot;modeName&quot;:&quot;php&quot;}">// Create DOM from URL
$html = file_get_html('http://slashdot.org/');

// Find all article blocks
foreach($html-&gt;find('div.article') as $article) {
    $item['title']     = $article-&gt;find('div.title', 0)-&gt;plaintext;
    $item['intro']    = $article-&gt;find('div.intro', 0)-&gt;plaintext;
    $item['details'] = $article-&gt;find('div.details', 0)-&gt;plaintext;
    $articles[] = $item;
}

print_r($articles);</pre></div>
]]></content:encoded>
					
					<wfw:commentRss>https://www.maxvergelli.com/how-to-parse-and-process-html-xml-in-php/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">239</post-id>	</item>
		<item>
		<title>Access a variable declared in a phtml from another phtml in Magento2</title>
		<link>https://www.maxvergelli.com/access-a-variable-declared-in-a-phtml-from-another-phtml-in-magento2/</link>
					<comments>https://www.maxvergelli.com/access-a-variable-declared-in-a-phtml-from-another-phtml-in-magento2/#respond</comments>
		
		<dc:creator><![CDATA[Max]]></dc:creator>
		<pubDate>Tue, 14 Apr 2020 16:25:00 +0000</pubDate>
				<category><![CDATA[Design]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[XML]]></category>
		<category><![CDATA[block]]></category>
		<category><![CDATA[blocks]]></category>
		<category><![CDATA[catalog-product-view]]></category>
		<category><![CDATA[custom-block]]></category>
		<category><![CDATA[custom-module]]></category>
		<category><![CDATA[global-variable]]></category>
		<category><![CDATA[magento]]></category>
		<category><![CDATA[magento2]]></category>
		<category><![CDATA[module]]></category>
		<category><![CDATA[phtml]]></category>
		<category><![CDATA[product-view]]></category>
		<category><![CDATA[template]]></category>
		<category><![CDATA[template-system]]></category>
		<category><![CDATA[variable]]></category>
		<guid isPermaLink="false">https://www.maxvergelli.com/?p=237</guid>

					<description><![CDATA[Having two blocks in the catalog_product_view.xml file like this: To access a variable declared in the first block from the second block, you can set the variable with register from the first phtml, then you get the value in the &#8230; <a class="kt-excerpt-readmore" href="https://www.maxvergelli.com/access-a-variable-declared-in-a-phtml-from-another-phtml-in-magento2/" aria-label="Access a variable declared in a phtml from another phtml in Magento2">Read More</a>]]></description>
										<content:encoded><![CDATA[
<p>Having two blocks in the <code>catalog_product_view.xml</code> file like this:</p>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;mode&quot;:&quot;xml&quot;,&quot;mime&quot;:&quot;application/xml&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:true,&quot;lineWrapping&quot;:true,&quot;readOnly&quot;:true,&quot;language&quot;:&quot;XML&quot;,&quot;modeName&quot;:&quot;xml&quot;}">&lt;block class=&quot;Magento\Catalog\Block\Product\View&quot; name=&quot;product.info.custom-product-attributes&quot; template=&quot;product/view/custom-product-attributes.phtml&quot; after=&quot;product.info.overview&quot;/&gt;
...
&lt;block class=&quot;Magento\Catalog\Block\Product\View&quot; name=&quot;product.info.custom-estimated-delivery&quot; template=&quot;product/view/custom-estimated-delivery.phtml&quot; after=&quot;product.price.final&quot;/&gt;</pre></div>



<p>To access a variable declared in the first block from the second block, you can set the variable with <code>register</code> from the first phtml, then you get the value in the 2nd phtml with <code>registry</code></p>



<p>To do things well without injecting direclty the objectManager in phtml, you have to create some function your product block, so in your block : <code>app/code/Vendor/Modulename/Block/Custom.php</code>assuming that your variable name is : <code>$tech</code> add the following code:</p>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;mode&quot;:&quot;php&quot;,&quot;mime&quot;:&quot;text/x-php&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:true,&quot;lineWrapping&quot;:true,&quot;readOnly&quot;:true,&quot;language&quot;:&quot;PHP&quot;,&quot;modeName&quot;:&quot;php&quot;}">&lt;?php
namespace Vendor\Modulename\Block;

class Custom extends \Magento\Framework\View\Element\Template
{
    protected $_coreRegistry;

    public function __construct(
        ...
        \Magento\Framework\Registry $coreRegistry
    ) {
        ...
        $this-&gt;_coreRegistry = $coreRegistry;
    }

    /**
     * Set var data
     */
    public function setTechData($data)
    {
        $this-&gt;_coreRegistry-&gt;register('tech', $data);
    }

    /**
     * Get var data
     */
    public function getTechData()
    {
        return $this-&gt;_coreRegistry-&gt;registry('tech');
    }
}</pre></div>



<p>Then in your First phtml :</p>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;mode&quot;:&quot;php&quot;,&quot;mime&quot;:&quot;text/x-php&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:true,&quot;lineWrapping&quot;:true,&quot;readOnly&quot;:true,&quot;language&quot;:&quot;PHP&quot;,&quot;modeName&quot;:&quot;php&quot;}">&lt;?php $tech = 'Your Data here'; ?&gt;
&lt;?php $block-&gt;setTechData($tech); ?&gt;</pre></div>



<p>Then, in the Second phtml :</p>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;mode&quot;:&quot;php&quot;,&quot;mime&quot;:&quot;text/x-php&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:true,&quot;lineWrapping&quot;:true,&quot;readOnly&quot;:true,&quot;language&quot;:&quot;PHP&quot;,&quot;modeName&quot;:&quot;php&quot;}">&lt;?php $block-&gt;getTechData(); ?&gt; //you'll get your tech value here</pre></div>



<p>Besides, you can also do that in phtml to <strong>test</strong> without the block solution, </p>



<p>First phtml :</p>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;mode&quot;:&quot;php&quot;,&quot;mime&quot;:&quot;text/x-php&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:true,&quot;lineWrapping&quot;:true,&quot;readOnly&quot;:true,&quot;language&quot;:&quot;PHP&quot;,&quot;modeName&quot;:&quot;php&quot;}">&lt;?php 
$tech = 'Your Data here';
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$objectManager-&gt;create(&quot;Magento\Framework\Registry&quot;)-&gt;register('tech', $tech);
?&gt;</pre></div>



<p>Second phtml :</p>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;mode&quot;:&quot;php&quot;,&quot;mime&quot;:&quot;text/x-php&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:true,&quot;lineWrapping&quot;:true,&quot;readOnly&quot;:true,&quot;language&quot;:&quot;PHP&quot;,&quot;modeName&quot;:&quot;php&quot;}">&lt;?php 
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$techData = $objectManager-&gt;create(&quot;Magento\Framework\Registry&quot;)-&gt;registry('tech');
echo $techData;
?&gt;</pre></div>
]]></content:encoded>
					
					<wfw:commentRss>https://www.maxvergelli.com/access-a-variable-declared-in-a-phtml-from-another-phtml-in-magento2/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">237</post-id>	</item>
		<item>
		<title>Display the total number of days between two dates in PHP</title>
		<link>https://www.maxvergelli.com/how-to-display-total-number-of-days-between-two-dates-in-php/</link>
					<comments>https://www.maxvergelli.com/how-to-display-total-number-of-days-between-two-dates-in-php/#respond</comments>
		
		<dc:creator><![CDATA[Max]]></dc:creator>
		<pubDate>Fri, 10 Apr 2020 14:30:00 +0000</pubDate>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[String Manipulation Algorithms]]></category>
		<category><![CDATA[conversion]]></category>
		<category><![CDATA[count-days]]></category>
		<category><![CDATA[date]]></category>
		<category><![CDATA[date-conversion]]></category>
		<category><![CDATA[date-interval]]></category>
		<category><![CDATA[datetime]]></category>
		<category><![CDATA[filtering]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[object]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[time-difference]]></category>
		<guid isPermaLink="false">http://www.maxvergelli.com/?p=147</guid>

					<description><![CDATA[PHP: How to display the total number of days between two dates in PHP, using the DateTime class and compare them via diff() method]]></description>
										<content:encoded><![CDATA[<p>To count the total number of days between two dates, use the <code>DateTime</code> class and compare them via <code>diff()</code> method with the following few lines of code</p>


<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;mode&quot;:&quot;php&quot;,&quot;mime&quot;:&quot;text/x-php&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:true,&quot;lineWrapping&quot;:true,&quot;readOnly&quot;:true,&quot;language&quot;:&quot;PHP&quot;,&quot;modeName&quot;:&quot;php&quot;}">$date1 = new DateTime('2020-01-01'); 
$date2 = new DateTime('2020-02-15'); 
print_r($date1-&gt;diff($date2));</pre></div>



<p>And the output will be:</p>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;mode&quot;:&quot;javascript&quot;,&quot;mime&quot;:&quot;application/json&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:true,&quot;lineWrapping&quot;:true,&quot;readOnly&quot;:true,&quot;languageLabel&quot;:&quot;no&quot;,&quot;language&quot;:&quot;JSON&quot;,&quot;modeName&quot;:&quot;json&quot;}">DateInterval Object ( 
  [y] =&gt; 0 
  [m] =&gt; 1 
  [d] =&gt; 14 
  [h] =&gt; 0 
  [i] =&gt; 0 
  [s] =&gt; 0 
  [f] =&gt; 0 
  [weekday] =&gt; 0 
  [weekday_behavior] =&gt; 0 
  [first_last_day_of] =&gt; 0 
  [invert] =&gt; 0 
  [days] =&gt; 45 
  [special_type] =&gt; 0 
  [special_amount] =&gt; 0 
  [have_weekday_relative] =&gt; 0 
  [have_special_relative] =&gt; 0 
)</pre></div>
]]></content:encoded>
					
					<wfw:commentRss>https://www.maxvergelli.com/how-to-display-total-number-of-days-between-two-dates-in-php/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">147</post-id>	</item>
		<item>
		<title>Resize an image with the same aspect ratio or with custom and crop sizes in PHP</title>
		<link>https://www.maxvergelli.com/how-to-resize-an-image-with-the-same-aspect-ratio-or-with-custom-and-crop-sizes-in-php/</link>
					<comments>https://www.maxvergelli.com/how-to-resize-an-image-with-the-same-aspect-ratio-or-with-custom-and-crop-sizes-in-php/#respond</comments>
		
		<dc:creator><![CDATA[Max]]></dc:creator>
		<pubDate>Tue, 07 Apr 2020 14:33:47 +0000</pubDate>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[aspect-ratio]]></category>
		<category><![CDATA[crop]]></category>
		<category><![CDATA[custom-dimensions]]></category>
		<category><![CDATA[dimensions]]></category>
		<category><![CDATA[how-to]]></category>
		<category><![CDATA[image]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[php-class]]></category>
		<category><![CDATA[php-function]]></category>
		<category><![CDATA[resize]]></category>
		<category><![CDATA[resize-image]]></category>
		<guid isPermaLink="false">http://www.maxvergelli.com/?p=193</guid>

					<description><![CDATA[In this article, I will explain how to resize an image in two different ways resizing with custom dimensions keeping the same proportions/aspect ratio Method 1: Resizing with custom dimensions The most practical method in PHP to resize an image &#8230; <a class="kt-excerpt-readmore" href="https://www.maxvergelli.com/how-to-resize-an-image-with-the-same-aspect-ratio-or-with-custom-and-crop-sizes-in-php/" aria-label="Resize an image with the same aspect ratio or with custom and crop sizes in PHP">Read More</a>]]></description>
										<content:encoded><![CDATA[
<p>In this article, I will explain how to resize an image in two different ways</p>



<ul><li>resizing with custom dimensions</li><li>keeping the same proportions/aspect ratio</li></ul>



<p><strong>Method 1: Resizing with custom dimensions</strong><br><br>The most practical method in PHP to resize an image with custom and crop sizes (without keeping the original proportions/aspect ratio) is implementing the following function: </p>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;mode&quot;:&quot;php&quot;,&quot;mime&quot;:&quot;text/x-php&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:true,&quot;lineWrapping&quot;:true,&quot;readOnly&quot;:true,&quot;language&quot;:&quot;PHP&quot;,&quot;modeName&quot;:&quot;php&quot;}">function resize_image($file, $w, $h, $crop=false) {
    list($width, $height) = getimagesize($file);
    $r = $width / $height;
    if ($crop) {
        if ($width &gt; $height) {
            $width = ceil($width-($width*abs($r-$w/$h)));
        } else {
            $height = ceil($height-($height*abs($r-$w/$h)));
        }
        $newwidth = $w;
        $newheight = $h;
    } else {
        if ($w/$h &gt; $r) {
            $newwidth = $h*$r;
            $newheight = $h;
        } else {
            $newheight = $w/$r;
            $newwidth = $w;
        }
    }
    $src = imagecreatefromjpeg($file);
    $dst = imagecreatetruecolor($newwidth, $newheight);
    imagecopyresampled($dst, $src, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);

    return $dst;
}</pre></div>



<p>if you set the $crop value on <em>true</em>, the image will be cropped starting from the center, otherwise it will be resized with the new values of width and height</p>



<p><strong>Method 2: keeping the aspect ratio</strong></p>



<p>The second method implements the SimpleImage class by Simon Jarvis, save in a new *.php file the following class and <em>require_once</em> it in your current script</p>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;mode&quot;:&quot;php&quot;,&quot;mime&quot;:&quot;text/x-php&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:true,&quot;lineWrapping&quot;:true,&quot;readOnly&quot;:true,&quot;language&quot;:&quot;PHP&quot;,&quot;modeName&quot;:&quot;php&quot;}">/*
* File: SimpleImage.php
* Author: Simon Jarvis
* Copyright: 2006 Simon Jarvis
* Date: 08/11/06
* Link: http://www.white-hat-web-design.co.uk/blog/resizing-images-with-php/
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details:
* http://www.gnu.org/licenses/gpl.html
*
*/

class SimpleImage {

   var $image;
   var $image_type;

   function load($filename) {

      $image_info = getimagesize($filename);
      $this-&gt;image_type = $image_info[2];
      if( $this-&gt;image_type == IMAGETYPE_JPEG ) {

         $this-&gt;image = imagecreatefromjpeg($filename);
      } elseif( $this-&gt;image_type == IMAGETYPE_GIF ) {

         $this-&gt;image = imagecreatefromgif($filename);
      } elseif( $this-&gt;image_type == IMAGETYPE_PNG ) {

         $this-&gt;image = imagecreatefrompng($filename);
      }
   }
   function save($filename, $image_type=IMAGETYPE_JPEG, $compression=75, $permissions=null) {

      if( $image_type == IMAGETYPE_JPEG ) {
         imagejpeg($this-&gt;image,$filename,$compression);
      } elseif( $image_type == IMAGETYPE_GIF ) {

         imagegif($this-&gt;image,$filename);
      } elseif( $image_type == IMAGETYPE_PNG ) {

         imagepng($this-&gt;image,$filename);
      }
      if( $permissions != null) {

         chmod($filename,$permissions);
      }
   }
   function output($image_type=IMAGETYPE_JPEG) {

      if( $image_type == IMAGETYPE_JPEG ) {
         imagejpeg($this-&gt;image);
      } elseif( $image_type == IMAGETYPE_GIF ) {

         imagegif($this-&gt;image);
      } elseif( $image_type == IMAGETYPE_PNG ) {

         imagepng($this-&gt;image);
      }
   }
   function getWidth() {

      return imagesx($this-&gt;image);
   }
   function getHeight() {

      return imagesy($this-&gt;image);
   }
   function resizeToHeight($height) {

      $ratio = $height / $this-&gt;getHeight();
      $width = $this-&gt;getWidth() * $ratio;
      $this-&gt;resize($width,$height);
   }

   function resizeToWidth($width) {
      $ratio = $width / $this-&gt;getWidth();
      $height = $this-&gt;getheight() * $ratio;
      $this-&gt;resize($width,$height);
   }

   function scale($scale) {
      $width = $this-&gt;getWidth() * $scale/100;
      $height = $this-&gt;getheight() * $scale/100;
      $this-&gt;resize($width,$height);
   }

   function resize($width,$height) {
      $new_image = imagecreatetruecolor($width, $height);
      imagecopyresampled($new_image, $this-&gt;image, 0, 0, 0, 0, $width, $height, $this-&gt;getWidth(), $this-&gt;getHeight());
      $this-&gt;image = $new_image;
   }      

}
</pre></div>



<p>then you can instantiate the above class in the following way in your script, to resize an image keeping the same proportions:</p>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;mode&quot;:&quot;php&quot;,&quot;mime&quot;:&quot;text/x-php&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:true,&quot;lineWrapping&quot;:true,&quot;readOnly&quot;:true,&quot;language&quot;:&quot;PHP&quot;,&quot;modeName&quot;:&quot;php&quot;}">$filename = 'your filename here!';		

list($width, $height) = getimagesize($filename);
	
$max_width = 1920;
$max_height = 1080;
$new_width = 1280;
$new_height = 720;

if($width &gt;= $height){
  $ratio = $max_width / $width;
  $new_height = $height * $ratio;
} else {
  $ratio = $max_height / $height;
  $new_width = $width * $ratio;
}

$image = new SimpleImage();
$image-&gt;load($filename);
$image-&gt;resize($new_width, $new_height);
$image-&gt;save($filename);
</pre></div>
]]></content:encoded>
					
					<wfw:commentRss>https://www.maxvergelli.com/how-to-resize-an-image-with-the-same-aspect-ratio-or-with-custom-and-crop-sizes-in-php/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">193</post-id>	</item>
		<item>
		<title>How to use Associative Arrays in ASP</title>
		<link>https://www.maxvergelli.com/how-to-use-associative-arrays-in-asp/</link>
					<comments>https://www.maxvergelli.com/how-to-use-associative-arrays-in-asp/#respond</comments>
		
		<dc:creator><![CDATA[Max]]></dc:creator>
		<pubDate>Sat, 01 Feb 2020 16:03:13 +0000</pubDate>
				<category><![CDATA[Classic ASP]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[MS Access]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[VBScript]]></category>
		<category><![CDATA[array]]></category>
		<category><![CDATA[array-function]]></category>
		<category><![CDATA[asp]]></category>
		<category><![CDATA[asp-associative-array]]></category>
		<category><![CDATA[associative-array]]></category>
		<category><![CDATA[classic-asp]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[conversion]]></category>
		<category><![CDATA[data-layer]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[datetime-conversion]]></category>
		<category><![CDATA[enumerate]]></category>
		<category><![CDATA[enumerating]]></category>
		<category><![CDATA[extension]]></category>
		<category><![CDATA[filter]]></category>
		<category><![CDATA[filtering]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[helper-class]]></category>
		<category><![CDATA[isarray-function]]></category>
		<category><![CDATA[method]]></category>
		<category><![CDATA[module]]></category>
		<category><![CDATA[parse]]></category>
		<category><![CDATA[parsing]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[string]]></category>
		<category><![CDATA[string-conversion]]></category>
		<category><![CDATA[string-manipulation]]></category>
		<category><![CDATA[vbscript]]></category>
		<category><![CDATA[wrapper-class]]></category>
		<guid isPermaLink="false">http://www.maxvergelli.com/?p=78</guid>

					<description><![CDATA[First of all, You need to download the &#8220;Asp Associative Array class&#8221; then include the file &#8220;AssociativeArrayClass.asp&#8221; in your asp page. Right now, You can start declaring associative arrays in ASP with the following syntax: [sourcecode language=&#8221;vb&#8221;] Dim Person Set &#8230; <a class="kt-excerpt-readmore" href="https://www.maxvergelli.com/how-to-use-associative-arrays-in-asp/" aria-label="How to use Associative Arrays in ASP">Read More</a>]]></description>
										<content:encoded><![CDATA[<p>First of all, You need to download the <a href="http://sourceforge.net/projects/asp-assoc-array/">&#8220;Asp Associative Array class&#8221;</a> then include the file &#8220;AssociativeArrayClass.asp&#8221; in your asp page.</p>
<p>Right now, You can start declaring associative arrays in ASP with the following syntax:</p>
<p>[sourcecode language=&#8221;vb&#8221;]<br />
Dim Person<br />
Set Person = New AssociativeArray<br />
Person(&quot;name&quot;)    =   &quot;Max&quot;<br />
Person(&quot;surname&quot;) =   &quot;Vergelli&quot;<br />
Response.Write Person(&quot;name&quot;) &amp; &quot; &quot; &amp; Person(&quot;surname&quot;)<br />
[/sourcecode]</p>
<p>In the above example, the key &#8220;name&#8221; in &#8220;Person&#8221; object, stores &#8220;Max&#8221; value. You can set strings or integers for the key and <strong>any object/variant type for the relative value</strong>. However, You can not set key with Null or &#8220;&#8221; strings like the following:</p>
<p>[sourcecode language=&#8221;vb&#8221;]<br />
&#8216;invalid keys&#8230;<br />
Person(Null) = &quot;Null Key&quot;<br />
Person(&quot;&quot;) = &quot;Empty String&quot;<br />
Dim undefined<br />
Person(undefined) = &quot;Variable Not Initialized&quot;<br />
Response.Write Person(&quot;&quot;) &amp; Person(Null) &amp; Person(undefined)<br />
[/sourcecode]</p>
<p><strong>How to get every item of the associative array:</strong><br />
You can make a &#8220;For Each&#8221; loop on the array like in the following code</p>
<p>[sourcecode language=&#8221;vb&#8221;]<br />
For Each element In Person.Items<br />
   Response.Write element.Key &amp; &quot; : &quot; &amp; element.Value &amp; vbCrLf<br />
Next<br />
[/sourcecode]</p>
<p>&#8220;Person.Items&#8221; gets all the items inside the associative array and for each item You can get &#8220;Key&#8221; and &#8220;Value&#8221; properties.</p>
<p><strong>How to copy an associative array:</strong></p>
<p>[sourcecode language=&#8221;vb&#8221;]<br />
Dim Person_Clone             &#8216;it&#8217;s a Variant type<br />
Set Person_Clone = Person    &#8216;NOTE: Use &quot;Set&quot; statement!<br />
&#8216;print values<br />
Response.Write Person_Clone(&quot;name&quot;) &amp; &quot; &quot; &amp; Person_Clone(&quot;surname&quot;) &amp; vbCrLf<br />
&#8216;get each key/value<br />
For Each element In Person_Clone.Items<br />
   Response.Write element.Key &amp; &quot; : &quot; &amp; element.Value &amp; vbCrLf<br />
Next<br />
[/sourcecode]</p>
<p><strong>How to create nested associative arrays&#8230;</strong><br />
You can create infinite nested associative arrays and accessing them like the following:</p>
<p>[sourcecode language=&#8221;vb&#8221;]<br />
Dim Person<br />
Set Person = New AssociativeArray<br />
Person(&quot;name&quot;) = &quot;Max&quot;<br />
Person(&quot;surname&quot;) = &quot;Vergelli&quot;<br />
Dim People<br />
Set People = New AssociativeArray<br />
People(1) = Person<br />
People(2) = Person<br />
People(3) = Person<br />
Response.Write People(1)(&quot;name&quot;) &amp; &quot; &quot; &amp; People(1)(&quot;surname&quot;)<br />
[/sourcecode]</p>
<p>Besides, You can enumerate all the keys/values inside the &#8220;People&#8221; associative array object</p>
<p>[sourcecode language=&#8221;vb&#8221;]<br />
For Each element In People.Items<br />
   Dim el_person<br />
   Set el_person = element.Value<br />
   Response.Write el_person(&quot;name&quot;) &amp; &quot; : &quot; &amp; el_person(&quot;surname&quot;) &amp; vbCrLf<br />
Next<br />
[/sourcecode]</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.maxvergelli.com/how-to-use-associative-arrays-in-asp/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">78</post-id>	</item>
		<item>
		<title>VBScript Class to create easly Associative Arrays in ASP like in PHP</title>
		<link>https://www.maxvergelli.com/vbscript-class-to-create-easly-associative-arrays-in-asp-like-in-php/</link>
					<comments>https://www.maxvergelli.com/vbscript-class-to-create-easly-associative-arrays-in-asp-like-in-php/#respond</comments>
		
		<dc:creator><![CDATA[Max]]></dc:creator>
		<pubDate>Wed, 22 Jan 2020 15:53:47 +0000</pubDate>
				<category><![CDATA[Classic ASP]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[MS Access]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[VBScript]]></category>
		<category><![CDATA[algorithm]]></category>
		<category><![CDATA[array]]></category>
		<category><![CDATA[asp-associative-array]]></category>
		<category><![CDATA[associative-array]]></category>
		<category><![CDATA[class]]></category>
		<category><![CDATA[classic-asp]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[conversion]]></category>
		<category><![CDATA[data]]></category>
		<category><![CDATA[data-layer]]></category>
		<category><![CDATA[datatype]]></category>
		<category><![CDATA[extension]]></category>
		<category><![CDATA[filter]]></category>
		<category><![CDATA[filtering]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[helper-class]]></category>
		<category><![CDATA[method]]></category>
		<category><![CDATA[module]]></category>
		<category><![CDATA[ms-access]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[parse]]></category>
		<category><![CDATA[parsing]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[string]]></category>
		<category><![CDATA[string-manipulation]]></category>
		<category><![CDATA[structure]]></category>
		<category><![CDATA[vbscript]]></category>
		<category><![CDATA[wrapper-class]]></category>
		<guid isPermaLink="false">http://www.maxvergelli.com/?p=76</guid>

					<description><![CDATA[I&#8217;ve posted a project at Source Forge with an ASP/VBScript class to create easly associative arrays like in PHP; visit http://sourceforge.net/projects/asp-assoc-array/ It is possible also load in an associative-array the data coming from MySQL or MS Access databases, then You &#8230; <a class="kt-excerpt-readmore" href="https://www.maxvergelli.com/vbscript-class-to-create-easly-associative-arrays-in-asp-like-in-php/" aria-label="VBScript Class to create easly Associative Arrays in ASP like in PHP">Read More</a>]]></description>
										<content:encoded><![CDATA[<p>I&#8217;ve posted a project at Source Forge with an ASP/VBScript class to create easly associative arrays like in PHP; visit <a href="http://sourceforge.net/projects/asp-assoc-array/">http://sourceforge.net/projects/asp-assoc-array/</a></p>
<p>It is possible also load in an associative-array the data coming from MySQL or MS Access databases, then You can programmatically manage the structured data; You can also export associative arrays to XML.</p>
<p>Associative arrays are usefull when it is necessary manage many variables at once (for example when we pass multiple values at once to a method/function) or just to store data in a well structured array and reusing  its values anytime.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.maxvergelli.com/vbscript-class-to-create-easly-associative-arrays-in-asp-like-in-php/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">76</post-id>	</item>
		<item>
		<title>PHP Date or Datetime to MySQL Datetime and viceversa</title>
		<link>https://www.maxvergelli.com/php-date-or-datetime-to-mysql-datetime-and-viceversa/</link>
					<comments>https://www.maxvergelli.com/php-date-or-datetime-to-mysql-datetime-and-viceversa/#respond</comments>
		
		<dc:creator><![CDATA[Max]]></dc:creator>
		<pubDate>Sat, 21 Dec 2019 15:10:11 +0000</pubDate>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[String Manipulation Algorithms]]></category>
		<category><![CDATA[algorithm]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[conversion]]></category>
		<category><![CDATA[conversione]]></category>
		<category><![CDATA[data-layer]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[date]]></category>
		<category><![CDATA[datetime]]></category>
		<category><![CDATA[datetime-conversion]]></category>
		<category><![CDATA[db]]></category>
		<category><![CDATA[extension]]></category>
		<category><![CDATA[filter]]></category>
		<category><![CDATA[filtering]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[helper-class]]></category>
		<category><![CDATA[method]]></category>
		<category><![CDATA[module]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[mysql-datetime]]></category>
		<category><![CDATA[mysql-datetime-conversion]]></category>
		<category><![CDATA[parse]]></category>
		<category><![CDATA[parsing]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[string]]></category>
		<category><![CDATA[string-conversion]]></category>
		<category><![CDATA[string-manipulation]]></category>
		<guid isPermaLink="false">http://www.maxvergelli.com/?p=59</guid>

					<description><![CDATA[Two useful PHP functions to convert normal date/datetime (&#8220;25.12.2010 12:10:00&#8221; or &#8220;25.12.2010&#8221;) to MySQL datetime (like &#8220;2010-12-25 12:10:00&#8221; or &#8220;2010-12-25 00:00:00&#8243;); You can get back a date/datetime from MySQL datetime too: [sourcecode language=&#8221;php&#8221;] function datetime2mysqldatetime($datetime){ // &#8216;25.12.2010 12:10:00&#8217; -&#62; &#8216;2010-12-25 &#8230; <a class="kt-excerpt-readmore" href="https://www.maxvergelli.com/php-date-or-datetime-to-mysql-datetime-and-viceversa/" aria-label="PHP Date or Datetime to MySQL Datetime and viceversa">Read More</a>]]></description>
										<content:encoded><![CDATA[<p>Two useful PHP functions to convert normal date/datetime (&#8220;25.12.2010 12:10:00&#8221; or &#8220;25.12.2010&#8221;) to MySQL datetime (like &#8220;2010-12-25 12:10:00&#8221; or &#8220;2010-12-25 00:00:00&#8243;); You can get back a date/datetime from MySQL datetime too:</p>
<p>[sourcecode language=&#8221;php&#8221;]<br />
	function datetime2mysqldatetime($datetime){				// &#8216;25.12.2010 12:10:00&#8217; -&gt; &#8216;2010-12-25 12:10:00&#8217;<br />
		return date(&#8216;Y-m-d H:i:s&#8217;, strtotime($datetime)); 	// &#8216;25.12.2010&#8217; 		 -&gt; &#8216;2010-12-25 00:00:00&#8217;<br />
	}</p>
<p>	function mysqldatetime2datetime($mysql_datetime){	// &#8216;2010-12-25 12:10:00&#8217; -&gt; &#8216;25.12.2010 12:10:00&#8217;<br />
		$d = split(&#8216; &#8216;, $mysql_datetime);				// &#8216;2010-12-25&#8217; 		 -&gt; &#8216;25.12.2010&#8217;<br />
		if($d &amp;&amp; count($d)&gt;1){<br />
			list($year, $month, $day) = split(&#8216;-&#8216;, $d[0]);<br />
			list($hour, $minute, $second) = split(&#8216;:&#8217;, $d[1]);<br />
			$d = date(&#8216;d.m.Y H:i:s&#8217;, mktime($hour, $minute, $second, $month, $day, $year));}<br />
		else if($d &amp;&amp; count($d)==1){<br />
			list($year, $month, $day) = split(&#8216;-&#8216;, $d[0]);<br />
			$d = date(&#8216;d.m.Y&#8217;, mktime(0, 0, 0, $month, $day, $year));<br />
		} else {<br />
			$d = NULL;<br />
		}<br />
		return $d;<br />
	}<br />
[/sourcecode]</p>
<p>Max 🙂</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.maxvergelli.com/php-date-or-datetime-to-mysql-datetime-and-viceversa/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">59</post-id>	</item>
		<item>
		<title>Easy-to-use and strong Encrypt/Decrypt PHP functions</title>
		<link>https://www.maxvergelli.com/easy-to-use-strong-encrypt-decrypt-php-functions/</link>
					<comments>https://www.maxvergelli.com/easy-to-use-strong-encrypt-decrypt-php-functions/#comments</comments>
		
		<dc:creator><![CDATA[Max]]></dc:creator>
		<pubDate>Tue, 10 Dec 2019 15:04:26 +0000</pubDate>
				<category><![CDATA[Cryptography]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[algorithm]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[conversion]]></category>
		<category><![CDATA[cryptography]]></category>
		<category><![CDATA[decryption]]></category>
		<category><![CDATA[encryption]]></category>
		<category><![CDATA[filter]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[hash]]></category>
		<category><![CDATA[hashing]]></category>
		<category><![CDATA[MD5]]></category>
		<category><![CDATA[method]]></category>
		<category><![CDATA[parsing]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[rijndael]]></category>
		<category><![CDATA[SHA1]]></category>
		<category><![CDATA[SHA256]]></category>
		<category><![CDATA[string]]></category>
		<category><![CDATA[String-class]]></category>
		<category><![CDATA[string-manipulation]]></category>
		<guid isPermaLink="false">http://www.maxvergelli.com/?p=57</guid>

					<description><![CDATA[I wrote those two following PHP functions to encrypt and decrypt strings easly and with a stronger encryption module than the other examples on the net (please, note that &#8220;strong&#8221; does not equals &#8220;secure&#8221;!); Happy encryption/decryption! 🙂 Max [sourcecode language=&#8221;php&#8221;] &#8230; <a class="kt-excerpt-readmore" href="https://www.maxvergelli.com/easy-to-use-strong-encrypt-decrypt-php-functions/" aria-label="Easy-to-use and strong Encrypt/Decrypt PHP functions">Read More</a>]]></description>
										<content:encoded><![CDATA[<p>I wrote those two following PHP functions to encrypt and decrypt strings easly and with a stronger encryption module than the other examples on the net (please, note that &#8220;strong&#8221; does not equals &#8220;secure&#8221;!);</p>
<p>Happy encryption/decryption! 🙂</p>
<p>Max</p>
<p>[sourcecode language=&#8221;php&#8221;]<br />
	function encrypt($input_string, $key){<br />
		$iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB);<br />
		$iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);<br />
		$h_key = hash(&#8216;sha256&#8217;, $key, TRUE);<br />
		return base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $h_key, $input_string, MCRYPT_MODE_ECB, $iv));<br />
	}</p>
<p>	function decrypt($encrypted_input_string, $key){<br />
		$iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB);<br />
		$iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);<br />
		$h_key = hash(&#8216;sha256&#8217;, $key, TRUE);<br />
		return trim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $h_key, base64_decode($encrypted_input_string), MCRYPT_MODE_ECB, $iv));<br />
	}<br />
[/sourcecode]</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.maxvergelli.com/easy-to-use-strong-encrypt-decrypt-php-functions/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">57</post-id>	</item>
	</channel>
</rss>
