Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #17642
| From | "Christoph M. Becker" <cmbecker69@arcor.de> |
|---|---|
| Newsgroups | comp.lang.php |
| Subject | Re: array_filter with two conditions |
| Date | 2018-01-05 13:29 +0100 |
| Organization | solani.org |
| Message-ID | <p2nr3h$u2c$1@solani.org> (permalink) |
| References | <fe3760f6-83ed-47b3-8402-880fd3d26408@googlegroups.com> |
On 05.01.2018 at 01:11, 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?
Why do you want to filter the array for this purpose? It seems to me
the simplest approach would be to iterate over the array, and then
conditionally printing what is desired. For instance:
<?php
$arr = array(1,2,6,7,9,4,10,11,12,3,13,24);
foreach ($arr as $val) {
echo ($val%2 ? "odd" : $val), PHP_EOL;
}
--
Christoph M. Becker
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