<?xml version="1.0" encoding="UTF-8"?><rss
version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
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/"
> <channel><title>Comments on: PHP &#8211; possible combinations between multiple array elements</title> <atom:link href="http://ask.amoeba.co.in/php-combinations-of-array-elements/feed/" rel="self" type="application/rss+xml" /><link>http://ask.amoeba.co.in/php-combinations-of-array-elements/</link> <description>Providing solutions for PHP, MySQL, Flash, Flex, Action Script, Javascript, YUI, JQuery, CSS, XHTML problems.</description> <lastBuildDate>Fri, 13 Jan 2012 20:50:44 +0000</lastBuildDate> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.2.1</generator> <item><title>By: Chris</title><link>http://ask.amoeba.co.in/php-combinations-of-array-elements/comment-page-1/#comment-2256</link> <dc:creator>Chris</dc:creator> <pubDate>Fri, 03 Jun 2011 13:00:35 +0000</pubDate> <guid
isPermaLink="false">http://ask.amoeba.co.in/?p=72#comment-2256</guid> <description>Thanks for this tutorial. I have been trying to do something similar, but just can not figure it out. I was wondering if you could provide some insight. I have a SQL statement that creates a multidimensional array that consist of times that are in a sequence of at least four consecutive order:
Array
(
[0] =&gt; Array
(
[0] =&gt; 13:00:00
[1] =&gt; 14:00:00
[2] =&gt; 15:00:00
[3] =&gt; 16:00:00
)
[1] =&gt; Array
(
[0] =&gt; 18:00:00
[1] =&gt; 19:00:00
[2] =&gt; 20:00:00
[3] =&gt; 21:00:00
[4] =&gt; 22:00:00
)
)
What I want to do is create check boxes for each possible 4 hours with a start and end time:
Checkbox 1 = 9:00 am – 12:00 pm
Checkbox 2 = 10:00 am – 1:00 pm
Checkbox 3 = 11:00 am – 2:00 pm
And so on…
Any thoughts?</description> <content:encoded><![CDATA[<p>Thanks for this tutorial. I have been trying to do something similar, but just can not figure it out. I was wondering if you could provide some insight. I have a SQL statement that creates a multidimensional array that consist of times that are in a sequence of at least four consecutive order:</p><p>Array<br
/> (<br
/> [0] =&gt; Array<br
/> (<br
/> [0] =&gt; 13:00:00<br
/> [1] =&gt; 14:00:00<br
/> [2] =&gt; 15:00:00<br
/> [3] =&gt; 16:00:00<br
/> )</p><p> [1] =&gt; Array<br
/> (<br
/> [0] =&gt; 18:00:00<br
/> [1] =&gt; 19:00:00<br
/> [2] =&gt; 20:00:00<br
/> [3] =&gt; 21:00:00<br
/> [4] =&gt; 22:00:00<br
/> )</p><p>)</p><p>What I want to do is create check boxes for each possible 4 hours with a start and end time:</p><p>Checkbox 1 = 9:00 am – 12:00 pm<br
/> Checkbox 2 = 10:00 am – 1:00 pm<br
/> Checkbox 3 = 11:00 am – 2:00 pm</p><p>And so on…</p><p>Any thoughts?</p> ]]></content:encoded> </item> <item><title>By: R. Hanouwer</title><link>http://ask.amoeba.co.in/php-combinations-of-array-elements/comment-page-1/#comment-2168</link> <dc:creator>R. Hanouwer</dc:creator> <pubDate>Mon, 16 May 2011 17:56:22 +0000</pubDate> <guid
isPermaLink="false">http://ask.amoeba.co.in/?p=72#comment-2168</guid> <description>My solution to the problem:
function combine($r, $c = &#039;&#039;) {
if($s = (array)array_shift($r)) foreach($s as $p) foreach(combine($r, $c) as $t) $o[] = $p.$t; else return (array)$c;
return $o;
}</description> <content:encoded><![CDATA[<p>My solution to the problem:</p><p>function combine($r, $c = &#8221;) {<br
/> if($s = (array)array_shift($r)) foreach($s as $p) foreach(combine($r, $c) as $t) $o[] = $p.$t; else return (array)$c;<br
/> return $o;<br
/> }</p> ]]></content:encoded> </item> <item><title>By: malczu</title><link>http://ask.amoeba.co.in/php-combinations-of-array-elements/comment-page-1/#comment-1896</link> <dc:creator>malczu</dc:creator> <pubDate>Sat, 20 Nov 2010 15:08:40 +0000</pubDate> <guid
isPermaLink="false">http://ask.amoeba.co.in/?p=72#comment-1896</guid> <description>Version without global:
$a = array(&quot;01&quot;, &quot;02&quot;);
$b = array(&quot;white&quot;, &quot;green&quot;);
$c = array(&quot;one&quot;, &quot;two&quot;, &quot;three&quot;);
$aG = array($a, $b, $c);
$aG = array(&#039;asdf&#039;=&gt;$a, &#039;color&#039;=&gt;$b, &#039;yxcv&#039;=&gt;$c);
$out = generateCodes($param);
function generateCodes($arr, &amp;$out = array(), $codes = array(), $pos = 0) {
if(count($arr)) {
$first_count = count(current($arr));
foreach( current($arr) as $item) {
$tmp = $arr;
$codes[$pos] = $item;
$tarr = array_shift($tmp);
$pos++;
generateCodes($tmp, $out, $codes, $pos);
$pos--;
}
} else {
$out[] = $codes;
}
return $out;
}</description> <content:encoded><![CDATA[<p>Version without global:</p><p>$a = array(&#8220;01&#8243;, &#8220;02&#8243;);<br
/> $b = array(&#8220;white&#8221;, &#8220;green&#8221;);<br
/> $c = array(&#8220;one&#8221;, &#8220;two&#8221;, &#8220;three&#8221;);<br
/> $aG = array($a, $b, $c);<br
/> $aG = array(&#8216;asdf&#8217;=&gt;$a, &#8216;color&#8217;=&gt;$b, &#8216;yxcv&#8217;=&gt;$c);</p><p> $out = generateCodes($param);</p><p>function generateCodes($arr, &amp;$out = array(), $codes = array(), $pos = 0) {<br
/> if(count($arr)) {<br
/> $first_count = count(current($arr));<br
/> foreach( current($arr) as $item) {<br
/> $tmp = $arr;<br
/> $codes[$pos] = $item;<br
/> $tarr = array_shift($tmp);<br
/> $pos++;<br
/> generateCodes($tmp, $out, $codes, $pos);<br
/> $pos&#8211;;<br
/> }<br
/> } else {<br
/> $out[] = $codes;<br
/> }</p><p> return $out;<br
/> }</p> ]]></content:encoded> </item> <item><title>By: Aneeska</title><link>http://ask.amoeba.co.in/php-combinations-of-array-elements/comment-page-1/#comment-1805</link> <dc:creator>Aneeska</dc:creator> <pubDate>Wed, 25 Aug 2010 10:49:30 +0000</pubDate> <guid
isPermaLink="false">http://ask.amoeba.co.in/?p=72#comment-1805</guid> <description>Cool Dan!
Thanks,
Anees</description> <content:encoded><![CDATA[<p>Cool Dan!</p><p>Thanks,<br
/> Anees</p> ]]></content:encoded> </item> <item><title>By: Dan</title><link>http://ask.amoeba.co.in/php-combinations-of-array-elements/comment-page-1/#comment-1804</link> <dc:creator>Dan</dc:creator> <pubDate>Wed, 25 Aug 2010 10:31:45 +0000</pubDate> <guid
isPermaLink="false">http://ask.amoeba.co.in/?p=72#comment-1804</guid> <description>Thanks for sharing. Here&#039;s the associative version:
&lt;code&gt;
header(&#039;Content-Type: text/plain&#039;);
$a = array(&quot;01&quot;, &quot;02&quot;);
$b = array(&quot;white&quot;, &quot;green&quot;);
$c = array(&quot;one&quot;, &quot;two&quot;, &quot;three&quot;);
$aG = array($a, $b, $c);
$aG = array(&#039;asdf&#039;=&gt;$a, &#039;color&#039;=&gt;$b, &#039;yxcv&#039;=&gt;$c);
$codes = array();
$pos = 0;
generateCodes($aG);
function generateCodes($arr) {
global $codes, $pos;
if (count($arr)) {
for ($i = 0, $c=count($arr[key($arr)]); $i &lt; $c; $i++) {
$tmp = $arr;
$codes[key($arr)] = $arr[key($arr)][$i];
$tarr = array_shift($tmp);
$pos++;
generateCodes($tmp);
}
} else {
print_r($codes);
}
$pos--;
}
&lt;/code&gt;</description> <content:encoded><![CDATA[<p>Thanks for sharing. Here&#8217;s the associative version:<br
/> <code><br
/> header('Content-Type: text/plain');</p><p>$a = array("01", "02");<br
/> $b = array("white", "green");<br
/> $c = array("one", "two", "three");<br
/> $aG = array($a, $b, $c);<br
/> $aG = array('asdf'=&gt;$a, 'color'=&gt;$b, 'yxcv'=&gt;$c);<br
/> $codes = array();<br
/> $pos = 0;<br
/> generateCodes($aG);</p><p>function generateCodes($arr) {<br
/> global $codes, $pos;<br
/> if (count($arr)) {<br
/> for ($i = 0, $c=count($arr[key($arr)]); $i &lt; $c; $i++) {<br
/> $tmp = $arr;<br
/> $codes[key($arr)] = $arr[key($arr)][$i];<br
/> $tarr = array_shift($tmp);<br
/> $pos++;<br
/> generateCodes($tmp);<br
/> }<br
/> } else {<br
/> print_r($codes);<br
/> }<br
/> $pos--;<br
/> }<br
/> </code></p> ]]></content:encoded> </item> <item><title>By: Abhinaya Panigrahi</title><link>http://ask.amoeba.co.in/php-combinations-of-array-elements/comment-page-1/#comment-297</link> <dc:creator>Abhinaya Panigrahi</dc:creator> <pubDate>Fri, 26 Mar 2010 05:28:01 +0000</pubDate> <guid
isPermaLink="false">http://ask.amoeba.co.in/?p=72#comment-297</guid> <description>Hi
Realy u people are doing well.
by using this code i only want to say waaaaaooooooo.........
Thanks
Abhi</description> <content:encoded><![CDATA[<p>Hi</p><p>Realy u people are doing well.<br
/> by using this code i only want to say waaaaaooooooo&#8230;&#8230;&#8230;</p><p>Thanks<br
/> Abhi</p> ]]></content:encoded> </item> </channel> </rss>
