snipt

Ctrl+h for KB shortcuts

Text only

PHP Unset all variables

foreach (array_keys($GLOBALS) as $k) unset($$k);
unset($k);
https://snipt.net/embed/3dc502278b0f6993c73ed871cd80a420/
https://snipt.net/raw/3dc502278b0f6993c73ed871cd80a420/
3dc502278b0f6993c73ed871cd80a420
text
Text only
3
2016-10-01T08:15:24
True
False
False
Jun 20, 2016 at 06:27 PM
/api/public/snipt/147262/
php-unset-all-variables
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a>foreach (array_keys($GLOBALS) as $k) unset($$k); </span><span id="L-2"><a name="L-2"></a>unset($k); </span></pre></div> </td></tr></table>
php

PHP

Generate random hex color

1
2
3
4
5
<?php

$color = '#'.str_pad(dechex(rand(0,255)), 2, 0).str_pad(dechex(rand(0,255)), 2, 0).str_pad(dechex(rand(0,255)), 2, 0);

?>
https://snipt.net/embed/6cf0e2b075edfb2514c35c15e9f17dc4/
https://snipt.net/raw/6cf0e2b075edfb2514c35c15e9f17dc4/
6cf0e2b075edfb2514c35c15e9f17dc4
php
PHP
5
2016-10-01T08:17:43
True
False
False
/api/public/snipt/147047/
generate-random-hex-color
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a><span class="cp">&lt;?php</span> </span><span id="L-2"><a name="L-2"></a> </span><span id="L-3"><a name="L-3"></a><span class="nv">$color</span> <span class="o">=</span> <span class="s1">&#39;#&#39;</span><span class="o">.</span><span class="nb">str_pad</span><span class="p">(</span><span class="nb">dechex</span><span class="p">(</span><span class="nb">rand</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span><span class="mi">255</span><span class="p">)),</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span><span class="o">.</span><span class="nb">str_pad</span><span class="p">(</span><span class="nb">dechex</span><span class="p">(</span><span class="nb">rand</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span><span class="mi">255</span><span class="p">)),</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span><span class="o">.</span><span class="nb">str_pad</span><span class="p">(</span><span class="nb">dechex</span><span class="p">(</span><span class="nb">rand</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span><span class="mi">255</span><span class="p">)),</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">0</span><span class="p">);</span> </span><span id="L-4"><a name="L-4"></a> </span><span id="L-5"><a name="L-5"></a><span class="cp">?&gt;</span><span class="x"></span> </span></pre></div> </td></tr></table>
color, hex, php
Copyrighted, illegal, or inappropriate content? Email support@snipt.net.