Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #17639
| From | Jerry Stuckle <jstucklex@attglobal.net> |
|---|---|
| Newsgroups | comp.lang.php |
| Subject | Re: array_filter with two conditions |
| Date | 2018-01-04 20:03 -0500 |
| Organization | A noiseless patient Spider |
| Message-ID | <p2misc$c6f$2@jstuckle.eternal-september.org> (permalink) |
| References | <fe3760f6-83ed-47b3-8402-880fd3d26408@googlegroups.com> |
On 1/4/2018 7:11 PM, jans wrote:
> I am having trouble debugging this? I can't get it to print out the value if it is even or the word "odd" if it is odd? The initial funcitons work but I don't know how to use the array_filter with two conditions? thanks,
> function odd($var)
> {
> // returns whether the input integer is odd
> return($var & 1);
> }
>
> function even($var)
> {
> // returns whether the input integer is even
> return(!($var & 1));
> }
>
> $arr = array(1,2,6,7,9,4,10,11,12,3,13,24);
> $keys = array_keys($arr);
>
> for ($counter = 0, $length = count($arr);$counter < $length; $counter++)
> {
> $key = $keys[$counter];
> $value = $array[$key];
> if ($arr_filter($arr,'even')==1){
> print_r($array[$key];);
> }elseif($arr_filter($arr,'odd')==1)
> {
> print_r('odd');
> }
> }
>
See my reply to your previous message.
Also, people here volunteer their help; don't expect an answer right
away. We respond when we get on and have time. If you don't get an
answer within a couple of days then you can bump it.
--
==================
Remove the "x" from my email address
Jerry Stuckle
jstucklex@attglobal.net
==================
Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
array_filter with two conditions jans <janis.rough@gmail.com> - 2018-01-04 16:11 -0800
Re: array_filter with two conditions Jerry Stuckle <jstucklex@attglobal.net> - 2018-01-04 20:03 -0500
Re: array_filter with two conditions Arno Welzel <usenet@arnowelzel.de> - 2018-01-05 02:10 +0100
Re: array_filter with two conditions "Christoph M. Becker" <cmbecker69@arcor.de> - 2018-01-05 13:29 +0100
Re: array_filter with two conditions jans <janis.rough@gmail.com> - 2018-01-08 14:29 -0800
Re: array_filter with two conditions Postiljon Petskin <yyyyyyyyyyyywwwww@zohomail.eu> - 2023-04-22 08:47 -0700
csiph-web