<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" version="2.0">
  <channel>
    <title><![CDATA[Content with Style - Comments on php: array_filter and callback function]]></title>
    <link>http://www.contentwithstyle.co.uk/feeds/rss/comments/101</link>
    <description><![CDATA[]]></description>
    <pubDate>Tue, 06 Jan 2009 02:55:51 +0000</pubDate>
    <generator>Zend_Feed</generator>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <item>
      <title><![CDATA[Content with Style - Comment #1 on php: array_filter and callback function]]></title>
      <link>http://www.contentwithstyle.co.uk/content/php-arrayfilter-and-callback-function/#comment-560</link>
      <guid>http://www.contentwithstyle.co.uk/content/php-arrayfilter-and-callback-function/#comment-560</guid>
      <description><![CDATA[thanx-a-lot, pascal. a few days ago i had quite a bit of troublewhen i tried to define a class-based callback function for array_filter.<br />
<br />
is this definition also working in php5?]]></description>
      <content:encoded><![CDATA[thanx-a-lot, pascal. a few days ago i had quite a bit of troublewhen i tried to define a class-based callback function for array_filter.<br />
<br />
is this definition also working in php5?]]></content:encoded>
      <pubDate>Thu, 20 Apr 2006 15:06:02 +0000</pubDate>
    </item>
    <item>
      <title><![CDATA[Content with Style - Comment #2 on php: array_filter and callback function]]></title>
      <link>http://www.contentwithstyle.co.uk/content/php-arrayfilter-and-callback-function/#comment-562</link>
      <guid>http://www.contentwithstyle.co.uk/content/php-arrayfilter-and-callback-function/#comment-562</guid>
      <description><![CDATA[Glad I could help. This should do:<br />
<pre>
$arr = array_filter($arr, array(&quot;self&quot;, &quot;filter&quot;));
</pre>
]]></description>
      <content:encoded><![CDATA[Glad I could help. This should do:<br />
<pre>
$arr = array_filter($arr, array(&quot;self&quot;, &quot;filter&quot;));
</pre>
]]></content:encoded>
      <pubDate>Fri, 21 Apr 2006 01:33:59 +0000</pubDate>
    </item>
    <item>
      <title><![CDATA[Content with Style - Comment #3 on php: array_filter and callback function]]></title>
      <link>http://www.contentwithstyle.co.uk/content/php-arrayfilter-and-callback-function/#comment-1698</link>
      <guid>http://www.contentwithstyle.co.uk/content/php-arrayfilter-and-callback-function/#comment-1698</guid>
      <description><![CDATA[Hi there. I&#8217;m currently working with an big array, and i have to filter some info out of it. This tutorial really helps, but i neat some more info.<br />
<br />
The array is very multidimentional, like this:<br />
$array[&#8216;id&#8217;][&#8216;category&#8217;][&#8216;element&#8217;] = value.<br />
<br />
So i want to filter out all the ID&#8217;s wich don&#8217;t have the good Value in [&#8216;category&#8217;][&#8216;element&#8217;], how can i do this?<br />
<br />
couse the callback function only has $var, i cant give all the $ID&#8217;s:<br />
function filter($var)<br />
{<br />
  return($var[&#8217;$id&#8217;] == &#8217;$askedvalue&#8217;);<br />
}<br />
<br />
would work, but how can i add $id/$askedvalue in the array_filter($array, &#8216;callbackfunction&#8217;)?]]></description>
      <content:encoded><![CDATA[Hi there. I&#8217;m currently working with an big array, and i have to filter some info out of it. This tutorial really helps, but i neat some more info.<br />
<br />
The array is very multidimentional, like this:<br />
$array[&#8216;id&#8217;][&#8216;category&#8217;][&#8216;element&#8217;] = value.<br />
<br />
So i want to filter out all the ID&#8217;s wich don&#8217;t have the good Value in [&#8216;category&#8217;][&#8216;element&#8217;], how can i do this?<br />
<br />
couse the callback function only has $var, i cant give all the $ID&#8217;s:<br />
function filter($var)<br />
{<br />
  return($var[&#8217;$id&#8217;] == &#8217;$askedvalue&#8217;);<br />
}<br />
<br />
would work, but how can i add $id/$askedvalue in the array_filter($array, &#8216;callbackfunction&#8217;)?]]></content:encoded>
      <pubDate>Sat, 04 Nov 2006 14:16:22 +0000</pubDate>
    </item>
    <item>
      <title><![CDATA[Content with Style - Comment #4 on php: array_filter and callback function]]></title>
      <link>http://www.contentwithstyle.co.uk/content/php-arrayfilter-and-callback-function/#comment-1703</link>
      <guid>http://www.contentwithstyle.co.uk/content/php-arrayfilter-and-callback-function/#comment-1703</guid>
      <description><![CDATA[How about setting the variables as class members or globals?]]></description>
      <content:encoded><![CDATA[How about setting the variables as class members or globals?]]></content:encoded>
      <pubDate>Mon, 06 Nov 2006 11:06:15 +0000</pubDate>
    </item>
    <item>
      <title><![CDATA[Content with Style - Comment #5 on php: array_filter and callback function]]></title>
      <link>http://www.contentwithstyle.co.uk/content/php-arrayfilter-and-callback-function/#comment-2447</link>
      <guid>http://www.contentwithstyle.co.uk/content/php-arrayfilter-and-callback-function/#comment-2447</guid>
      <description><![CDATA[Hi thanks for this tut, I really need it, but I&#8217;m having trouble understanding the array filter. I need to make a loop from an array which calls in a simple flat file database for a site menu, the database contains the site menu link names i.e. my web page, and I need the array to filter that data stripping the spaces to return mywebpage.txt (where the actual page is) as well as pull in the link name, all within an li tag so the &#8220;my web page&#8221; shows up as the link name and the mywebpage.txt shows up as the link.  Here&#8217;s my function<br />
<br />
function filter_str($string, $page=&#8217;&#8217;)<br />
{<br />
if ($page == &#8216;&#8217;)<br />
   $filter = ereg_replace(&#8217;[^a-zA-Z0-9_]&#8217;, &#8216;&#8217;, $string);<br />
<br />
else <br />
   $filter = ereg_replace(&#8221;[^a-zA-Z0-9_$page]&#8221;, &#8216;&#8217;, $string);<br />
<br />
  return $filter;  <br />
}<br />
<br />
$page = filter_str($page);<br />
<br />
and my array loop<br />
<br />
$array = file(&#8220;menudata.txt&#8221;);//holds menu link names<br />
<br />
foreach($array as $page) {<br />
<br />
echo &#8220;li a href=&#8221;index.php?page=$page&#8221;{$page}/a/li>&#8221;;<br />
<br />
(i had to take the link lesser/greater tags out in this post to get them to show up.)<br />
<br />
for the life of me I cannot figure out how to make it work.<br />
Thanks for any help you have time to provide.<br />
<br />
Karen]]></description>
      <content:encoded><![CDATA[Hi thanks for this tut, I really need it, but I&#8217;m having trouble understanding the array filter. I need to make a loop from an array which calls in a simple flat file database for a site menu, the database contains the site menu link names i.e. my web page, and I need the array to filter that data stripping the spaces to return mywebpage.txt (where the actual page is) as well as pull in the link name, all within an li tag so the &#8220;my web page&#8221; shows up as the link name and the mywebpage.txt shows up as the link.  Here&#8217;s my function<br />
<br />
function filter_str($string, $page=&#8217;&#8217;)<br />
{<br />
if ($page == &#8216;&#8217;)<br />
   $filter = ereg_replace(&#8217;[^a-zA-Z0-9_]&#8217;, &#8216;&#8217;, $string);<br />
<br />
else <br />
   $filter = ereg_replace(&#8221;[^a-zA-Z0-9_$page]&#8221;, &#8216;&#8217;, $string);<br />
<br />
  return $filter;  <br />
}<br />
<br />
$page = filter_str($page);<br />
<br />
and my array loop<br />
<br />
$array = file(&#8220;menudata.txt&#8221;);//holds menu link names<br />
<br />
foreach($array as $page) {<br />
<br />
echo &#8220;li a href=&#8221;index.php?page=$page&#8221;{$page}/a/li>&#8221;;<br />
<br />
(i had to take the link lesser/greater tags out in this post to get them to show up.)<br />
<br />
for the life of me I cannot figure out how to make it work.<br />
Thanks for any help you have time to provide.<br />
<br />
Karen]]></content:encoded>
      <pubDate>Sun, 06 Jan 2008 10:12:38 +0000</pubDate>
    </item>
  </channel>
</rss>
