snipt

Ctrl+h for KB shortcuts

PHP

borrar tags html de un texto

1
2
3
4
<?php
$text = '<p>Test paragraph.</p><!-- Comment --> <a href="#fragment">Other text</a>';
echo strip_tags($text);
?>
https://snipt.net/embed/fb98f47d3affdc583f50a63157f788ca/
/raw/fb98f47d3affdc583f50a63157f788ca/
fb98f47d3affdc583f50a63157f788ca
php
PHP
4
2019-07-15T18:41:56
True
False
False
/api/public/snipt/13342/
borrar-tags-html-de-un-texto
<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></pre></div></td><td class="code"><div class="highlight"><pre><span></span><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 class="nv">$text</span> <span class="o">=</span> <span class="s1">&#39;&lt;p&gt;Test paragraph.&lt;/p&gt;&lt;!-- Comment --&gt; &lt;a href=&quot;#fragment&quot;&gt;Other text&lt;/a&gt;&#39;</span><span class="p">;</span> </span><span id="L-3"><a name="L-3"></a><span class="k">echo</span> <span class="nb">strip_tags</span><span class="p">(</span><span class="nv">$text</span><span class="p">);</span> </span><span id="L-4"><a name="L-4"></a><span class="cp">?&gt;</span><span class="x"></span> </span></pre></div> </td></tr></table>
clear, limpiar, php

PHP

Obtener fecha de ayer

1
2
3
<?php
echo date("d-m-Y",time()-86400);///Al día de hoy le restamos 86400 (60*60*24)
?>
https://snipt.net/embed/1e65c295b6630f66b452b6cd78602da7/
/raw/1e65c295b6630f66b452b6cd78602da7/
1e65c295b6630f66b452b6cd78602da7
php
PHP
3
2019-07-13T06:47:12
True
False
False
/api/public/snipt/13025/
obtener-fecha-de-ayer
<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></pre></div></td><td class="code"><div class="highlight"><pre><span></span><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 class="k">echo</span> <span class="nb">date</span><span class="p">(</span><span class="s2">&quot;d-m-Y&quot;</span><span class="p">,</span><span class="nb">time</span><span class="p">()</span><span class="o">-</span><span class="mi">86400</span><span class="p">);</span><span class="c1">///Al día de hoy le restamos 86400 (60*60*24)</span> </span><span id="L-3"><a name="L-3"></a><span class="cp">?&gt;</span><span class="x"></span> </span></pre></div> </td></tr></table>
fechas, php

SQL

Ordernar por año y mes

SELECT * FROM tabla ORDER by YEAR(fecha)='2009' DESC, MONTH(fecha)='8' DESC
https://snipt.net/embed/93345c4354b3d443f5aee78c98bbe3f6/
/raw/93345c4354b3d443f5aee78c98bbe3f6/
93345c4354b3d443f5aee78c98bbe3f6
sql
SQL
2
2019-07-13T20:10:20
True
False
False
/api/public/snipt/7821/
ordernar-por-ano-y-mes
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="k">SELECT</span> <span class="o">*</span> <span class="k">FROM</span> <span class="n">tabla</span> <span class="k">ORDER</span> <span class="k">by</span> <span class="k">YEAR</span><span class="p">(</span><span class="n">fecha</span><span class="p">)</span><span class="o">=</span><span class="s1">&#39;2009&#39;</span> <span class="k">DESC</span><span class="p">,</span> <span class="k">MONTH</span><span class="p">(</span><span class="n">fecha</span><span class="p">)</span><span class="o">=</span><span class="s1">&#39;8&#39;</span> <span class="k">DESC</span> </span></pre></div> </td></tr></table>
ordenar