Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #15590

Re: Refresher for array handling???

From Thomas 'PointedEars' Lahn <PointedEars@web.de>
Newsgroups comp.lang.php
Subject Re: Refresher for array handling???
Date 2015-07-17 21:24 +0200
Organization PointedEars Software (PES)
Message-ID <239530657.1smQKY0v18@PointedEars.de> (permalink)
References <lvbaqa189n0e1ldtgg1de1vprbjvs46es2@4ax.com> <55a6598d$0$2914$e4fe514c@news2.news.xs4all.nl>

Show all headers | View raw


Erwin Moller wrote:

> <?php
> $frq = array();
> $frq[12] = array(13.4, 17.4, 20.0);
> $frq[13] = array(3.5, 6.7, 17.3);
> $frq[19] = array(3.1, 194.45, 10.909);

DRY:

  $frq = array(
    12 => array(13.4, 17.4, 20.0),
    13 => array(3.5, 6.7, 17.3),
    19 => array(3.1, 194.45, 10.909)
  );

Since PHP 5.4:

  $frq = [
    12 => [13.4, 17.4, 20.0],
    13 => [3.5, 6.7, 17.3],
    19 => [3.1, 194.45, 10.909]
  ];
 
<http://php.net/manual/en/migration54.new-features.php>

> echo "<pre>";
> print_r($frq);
> echo "<pre>";
        ^^
  echo '<pre>' . print_r($frq, true) . '</pre>';

<http://php.net/print_r>

With the Xdebug extension enabled,

  var_dump($frq);

will generate the output using a fixed-width font by default, and you have 
more control over the output, such as the nesting level.

<http://xdebug.org/docs/display>

> ?>

Avoid this in PHP programs unless you are sure that you want what follows to 
be sent to the standard output.

<http://www.php-fig.org/psr/psr-2/> etc.
 
-- 
PointedEars
Zend Certified PHP Engineer
Twitter: @PointedEars2
Please do not cc me. / Bitte keine Kopien per E-Mail.

Back to comp.lang.php | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Refresher for array handling??? bobmct <r.mariotti@fdcx.net> - 2015-07-14 12:12 -0400
  Re: Refresher for array handling??? Erwin Moller <erwinmollerusenet@xs4all.nl> - 2015-07-15 15:01 +0200
    Re: Refresher for array handling??? Erwin Moller <erwinmollerusenet@xs4all.nl> - 2015-07-15 15:03 +0200
    Re: Refresher for array handling??? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-07-17 21:24 +0200
      Re: Refresher for array handling??? Erwin Moller <erwinmollerusenet@xs4all.nl> - 2015-07-20 16:30 +0200
        Re: Refresher for array handling??? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-07-20 19:45 +0200
          Re: Refresher for array handling??? Matthew Carter <m@ahungry.com> - 2015-07-20 22:36 -0400
          Re: Refresher for array handling??? Erwin Moller <erwinmollerusenet@xs4all.nl> - 2015-07-21 11:22 +0200
            Re: Refresher for array handling??? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-07-21 13:30 +0200
              Re: Refresher for array handling??? Erwin Moller <erwinmollerusenet@xs4all.nl> - 2015-07-21 14:03 +0200
        Re: Refresher for array handling??? Denis McMahon <denismfmcmahon@gmail.com> - 2015-07-21 01:01 +0000
          Re: Refresher for array handling??? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-07-21 09:07 +0200
  Re: Refresher for array handling??? "Christoph M. Becker" <cmbecker69@arcor.de> - 2015-07-15 20:18 +0200
  Re: Refresher for array handling??? Denis McMahon <denismfmcmahon@gmail.com> - 2015-07-17 02:51 +0000

csiph-web