snipt

Ctrl+h for KB shortcuts

PHP

Create an array with all query string params

1
2
3
4
5
6
$input_string = explode('&', $_SERVER["QUERY_STRING"]);

foreach ($input_string as $string_value) {
    $item = explode('=', $string_value);
    $input_array[$item[0]] = $item[1];
}
https://snipt.net/embed/bf5f396d2357d38cd8a41392efcc5fd8/
/raw/bf5f396d2357d38cd8a41392efcc5fd8/
bf5f396d2357d38cd8a41392efcc5fd8
php
PHP
6
2019-06-18T01:57:27
True
False
False
Mar 20, 2013 at 07:41 AM
/api/public/snipt/57993/
create-an-array-with-all-query-string-params
<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> <a href="#L-6">6</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="x">$input_string = explode(&#39;&amp;&#39;, $_SERVER[&quot;QUERY_STRING&quot;]);</span> </span><span id="L-2"><a name="L-2"></a> </span><span id="L-3"><a name="L-3"></a><span class="x">foreach ($input_string as $string_value) {</span> </span><span id="L-4"><a name="L-4"></a><span class="x"> $item = explode(&#39;=&#39;, $string_value);</span> </span><span id="L-5"><a name="L-5"></a><span class="x"> $input_array[$item[0]] = $item[1];</span> </span><span id="L-6"><a name="L-6"></a><span class="x">}</span> </span></pre></div> </td></tr></table>
"query string", arguments, parameters

JavaScript+Ruby

convert arguments to array

var args = Array.prototype.slice.call(arguments);
https://snipt.net/embed/f97f21c29d8e3832b1a882c687021070/
/raw/f97f21c29d8e3832b1a882c687021070/
f97f21c29d8e3832b1a882c687021070
js+erb
JavaScript+Ruby
1
2019-06-12T03:12:56
True
False
False
/api/public/snipt/15925/
convert-arguments-to-array
<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="kd">var</span> <span class="nx">args</span> <span class="o">=</span> <span class="nb">Array</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">slice</span><span class="p">.</span><span class="nx">call</span><span class="p">(</span><span class="nx">arguments</span><span class="p">);</span> </span></pre></div> </td></tr></table>
arguments, javascript