Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #19444
| Newsgroups | comp.lang.php |
|---|---|
| Date | 2023-04-22 08:47 -0700 |
| References | <fe3760f6-83ed-47b3-8402-880fd3d26408@googlegroups.com> |
| Message-ID | <f8b78183-a441-4e48-a45b-b2978006fa68n@googlegroups.com> (permalink) |
| Subject | Re: array_filter with two conditions |
| From | Postiljon Petskin <yyyyyyyyyyyywwwww@zohomail.eu> |
On Friday, January 5, 2018 at 2:11:50 AM UTC+2, 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');
> }
> }
You agree, that You are the most unoriginal person in the history of the universe ?
Back to comp.lang.php | Previous | Next | Find similar
Re: array_filter with two conditions Postiljon Petskin <yyyyyyyyyyyywwwww@zohomail.eu> - 2023-04-22 08:47 -0700
csiph-web