php-general Digest 14 Nov 2013 10:44:41 -0000 Issue 8425

Topics (messages 322447 through 322454):

Re: regarding print_r()
        322447 by: George Wilson
        322448 by: Shawn McKenzie
        322452 by: Tamara Temple
        322453 by: Sachin Raut

Date sequence calculating
        322449 by: Ron Piggott
        322450 by: Jonathan Sundquist
        322451 by: George Wilson

PHP 5.5.6 has been released
        322454 by: Julien Pauli

Administrivia:

To subscribe to the digest, e-mail:
        php-general-digest-subscr...@lists.php.net

To unsubscribe from the digest, e-mail:
        php-general-digest-unsubscr...@lists.php.net

To post to the list, e-mail:
        php-gene...@lists.php.net


----------------------------------------------------------------------
--- Begin Message ---
That is insanely awesome!

Thanks for passing that along.


On Tue, Nov 12, 2013 at 10:17 AM, Phred White <phpl...@planetphred.com>wrote:

> My fave:
>
> echo '<textarea> . print_r($a,true) . '</textarea>';
>
> - print_r's indents etc. maintained (as in <pre>)
> - default textarea is small and consistent size, doesn't disrupt layout
> even for massive arrays
> - you can resize at will (at least in Safari)
> - you can have multiples for complex problem solving and view them next to
> each other!
>
> On Nov 10, 2013, at 8:15 AM, Ken Robinson wrote:
>
> > A nice application of the second parameter is to get the output of
> print_r formatted on your web page:
> >
> > echo '<pre>' . print_r($ary, true) . '</pre>';
> >
> > much easier to read...
> >
> > Ken
> >
> > At 08:26 AM 11/10/2013, Sachin Raut wrote:
> >> Thank you Mr.Sperberg for telling about 2nd parameter. Really appreciate
> >> your help.
> >>
> >> Thanks
> >> Sachin Raut
> >>
> >>
> >> On Sun, Nov 10, 2013 at 2:39 PM, Camilo Sperberg <unrea...@gmail.com>
> wrote:
> >>
> >> >
> >> > On 10 nov. 2013, at 06:24, Sachin Raut <imsachinr...@gmail.com>
> wrote:
> >> >
> >> > > Issue resolved. I didn't notice that i was passing print_r()
> function to
> >> > > echo. Silly mistake.
> >> > >
> >> > > Thanks
> >> > > Sachin Raut
> >> > >
> >> > >
> >> > > On Sun, Nov 10, 2013 at 10:39 AM, Sachin Raut <
> imsachinr...@gmail.com
> >> > >wrote:
> >> > >
> >> > >> Hello,
> >> > >>
> >> > >>
> >> > >> I am trying to print following array using print_r(), but it
> appends
> >> > >> number "1" to the output. Can someone pls tell me what is the issue
> >> > here or
> >> > >> is there any setting i need to do in PHP.
> >> > >>
> >> > >>
> >> > >> Thanks
> >> > >>
> >> > >> Sachin Raut
> >> > >>
> >> > >>
> >> > >> <?php
> >> > >>
> >> > >> $a[]="Paris";
> >> > >>
> >> > >> $a[]="London";
> >> > >>
> >> > >> echo print_r($a);
> >> > >>
> >> > >> ?>
> >> > >>
> >> > >>
> >> > >> Output :
> >> > >>
> >> > >> Array ( [0] => Paris [1] => London ) 1
> >> > >>
> >> >
> >> > I think everyone on this list has made that same mistake once.
> >> >
> >> > Just as a sidenote, you can pass true as second parameter to have
> print_r
> >> > return the contents instead of printing them directly. It comes in
> very
> >> > handy in case you need to escape characters before printing or
> manipulate
> >> > the string before you want to print.
> >> >
> >> > Greetings.
> >> >
> >> > Met vriendelijke groet,
> >> > Camilo Sperberg
> >> >
> >> > ----------------
> >> > W: http://unreal4u.com
> >> > T: http://twitter.com/unreal4u
> >> >
> >> >
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--- End Message ---
--- Begin Message ---
FWIW, I use var_export() since it is valid PHP code and can be copy/pasted
etc.


On Sat, Nov 9, 2013 at 11:09 PM, Sachin Raut <imsachinr...@gmail.com> wrote:

> Hello,
>
>
> I am trying to print following array using print_r(), but it appends number
> "1" to the output. Can someone pls tell me what is the issue here or is
> there any setting i need to do in PHP.
>
>
> Thanks
>
> Sachin Raut
>
>
> <?php
>
>  $a[]="Paris";
>
> $a[]="London";
>
>  echo print_r($a);
>
> ?>
>
>
> Output :
>
> Array ( [0] => Paris [1] => London ) 1
>

--- End Message ---
--- Begin Message ---
+ for var_export()!
+ for textarea!


On Nov 12, 2013, at 1:17 PM, Shawn McKenzie <sh...@mckenzies.net> wrote:

> FWIW, I use var_export() since it is valid PHP code and can be copy/pasted
> etc.
> 
> 
> On Sat, Nov 9, 2013 at 11:09 PM, Sachin Raut <imsachinr...@gmail.com> wrote:
> 
>> Hello,
>> 
>> 
>> I am trying to print following array using print_r(), but it appends number
>> "1" to the output. Can someone pls tell me what is the issue here or is
>> there any setting i need to do in PHP.
>> 
>> 
>> Thanks
>> 
>> Sachin Raut
>> 
>> 
>> <?php
>> 
>> $a[]="Paris";
>> 
>> $a[]="London";
>> 
>> echo print_r($a);
>> 
>> ?>
>> 
>> 
>> Output :
>> 
>> Array ( [0] => Paris [1] => London ) 1
>> 


--- End Message ---
--- Begin Message ---
Wow...didn't know about textarea & var_export(). Really awesome.

thanks
Sachin Raut


On Wed, Nov 13, 2013 at 4:30 AM, Tamara Temple <tamouse.li...@gmail.com>wrote:

> + for var_export()!
> + for textarea!
>
>
> On Nov 12, 2013, at 1:17 PM, Shawn McKenzie <sh...@mckenzies.net> wrote:
>
> > FWIW, I use var_export() since it is valid PHP code and can be
> copy/pasted
> > etc.
> >
> >
> > On Sat, Nov 9, 2013 at 11:09 PM, Sachin Raut <imsachinr...@gmail.com>
> wrote:
> >
> >> Hello,
> >>
> >>
> >> I am trying to print following array using print_r(), but it appends
> number
> >> "1" to the output. Can someone pls tell me what is the issue here or is
> >> there any setting i need to do in PHP.
> >>
> >>
> >> Thanks
> >>
> >> Sachin Raut
> >>
> >>
> >> <?php
> >>
> >> $a[]="Paris";
> >>
> >> $a[]="London";
> >>
> >> echo print_r($a);
> >>
> >> ?>
> >>
> >>
> >> Output :
> >>
> >> Array ( [0] => Paris [1] => London ) 1
> >>
>
>

--- End Message ---
--- Begin Message ---
I am trying to calculate a date sequence using $i in conjunction with “ (so the 
represented # is “seen” by PHP)

The code (below) results in 2 errors:

Notice:  Undefined variable: i_days_ago in 
/vhosts/mypainmanagementtracker.net/public/test.php on line 9
Notice:  Undefined variable: i_days_ago in 
/vhosts/mypainmanagementtracker.net/public/test.php on line 13

<?php

    $users_current_date = date('Y-m-d');
    $i = 2;
    while ( $i <= 10 ) {

        $dt = new \DateTime( date('Y-m-d H:i:s' , strtotime( 
$users_current_date ) ) );
        $dt->modify("-$i days");
        $users_dates["$i_days_ago"]['starting_date'] = $dt->format('Y-m-d 
00:00:00');

        $dt = new \DateTime( date('Y-m-d H:i:s' , strtotime( 
$users_current_date ) ) );
        $dt->modify("-$i days");
        $users_dates["$i_days_ago"]['ending_date'] = $dt->format('Y-m-d 
23:59:59');

    ++$i;
    }
?>

Is there a way to do this without creating these errors and also “NOTICE” 
errors?  The dates being calculated will be used in a database query (used to 
generate a report based on the activity between the starting and ending dates). 

Ron


Ron Piggott


www.TheVerseOfTheDay.info 

--- End Message ---
--- Begin Message ---
On Tue, Nov 12, 2013 at 1:25 PM, Ron Piggott <ron.pigg...@actsministries.org
> wrote:

> I am trying to calculate a date sequence using $i in conjunction with “
> (so the represented # is “seen” by PHP)
>
> The code (below) results in 2 errors:
>
> Notice:  Undefined variable: i_days_ago in /vhosts/
> mypainmanagementtracker.net/public/test.php on line 9
> Notice:  Undefined variable: i_days_ago in /vhosts/
> mypainmanagementtracker.net/public/test.php on line 13
>
> <?php
>
>     $users_current_date = date('Y-m-d');
>     $i = 2;
>     while ( $i <= 10 ) {
>
>         $dt = new \DateTime( date('Y-m-d H:i:s' , strtotime(
> $users_current_date ) ) );
>         $dt->modify("-$i days");
>         $users_dates["$i_days_ago"]['starting_date'] = $dt->format('Y-m-d
> 00:00:00');
>
>         $dt = new \DateTime( date('Y-m-d H:i:s' , strtotime(
> $users_current_date ) ) );
>         $dt->modify("-$i days");
>         $users_dates["$i_days_ago"]['ending_date'] = $dt->format('Y-m-d
> 23:59:59');
>
>     ++$i;
>     }
> ?>
>
> Is there a way to do this without creating these errors and also “NOTICE”
> errors?  The dates being calculated will be used in a database query (used
> to generate a report based on the activity between the starting and ending
> dates).
>
> Ron
>
>
> Ron Piggott
>
>
> www.TheVerseOfTheDay.info
>

You need to concatenate the string. Right now php thinks that $i_days_ago
is a string since you have it in double quotes. You should do

$users_dates[$i . "_days_ago"]['starting_date'] = $dt->format('Y-m-d
00:00:00');
$users_dates[$i . "_days_ago"]["ending_date"] =  $dt->format('Y-m-d
23:59:59');

--- End Message ---
--- Begin Message ---
Or you could always do:

        $users_dates["{$i}_days_ago"]['starting_date'] = $dt->format('Y-m-d
00:00:00');

        $users_dates["{$i}_days_ago"]['ending_date'] = $dt->format('Y-m-d
23:59:59');


On Tue, Nov 12, 2013 at 11:30 AM, Jonathan Sundquist
<jsundqu...@gmail.com>wrote:

> On Tue, Nov 12, 2013 at 1:25 PM, Ron Piggott <
> ron.pigg...@actsministries.org
> > wrote:
>
> > I am trying to calculate a date sequence using $i in conjunction with “
> > (so the represented # is “seen” by PHP)
> >
> > The code (below) results in 2 errors:
> >
> > Notice:  Undefined variable: i_days_ago in /vhosts/
> > mypainmanagementtracker.net/public/test.php on line 9
> > Notice:  Undefined variable: i_days_ago in /vhosts/
> > mypainmanagementtracker.net/public/test.php on line 13
> >
> > <?php
> >
> >     $users_current_date = date('Y-m-d');
> >     $i = 2;
> >     while ( $i <= 10 ) {
> >
> >         $dt = new \DateTime( date('Y-m-d H:i:s' , strtotime(
> > $users_current_date ) ) );
> >         $dt->modify("-$i days");
> >         $users_dates["$i_days_ago"]['starting_date'] = $dt->format('Y-m-d
> > 00:00:00');
> >
> >         $dt = new \DateTime( date('Y-m-d H:i:s' , strtotime(
> > $users_current_date ) ) );
> >         $dt->modify("-$i days");
> >         $users_dates["$i_days_ago"]['ending_date'] = $dt->format('Y-m-d
> > 23:59:59');
> >
> >     ++$i;
> >     }
> > ?>
> >
> > Is there a way to do this without creating these errors and also “NOTICE”
> > errors?  The dates being calculated will be used in a database query
> (used
> > to generate a report based on the activity between the starting and
> ending
> > dates).
> >
> > Ron
> >
> >
> > Ron Piggott
> >
> >
> > www.TheVerseOfTheDay.info
> >
>
> You need to concatenate the string. Right now php thinks that $i_days_ago
> is a string since you have it in double quotes. You should do
>
> $users_dates[$i . "_days_ago"]['starting_date'] = $dt->format('Y-m-d
> 00:00:00');
> $users_dates[$i . "_days_ago"]["ending_date"] =  $dt->format('Y-m-d
> 23:59:59');
>

--- End Message ---
--- Begin Message ---
Hi!

The PHP development team announces the immediate availability of PHP 5.5.6.
This release fixes several bugs against PHP 5.5.5, and adds some
performance improvements for some functions.

All PHP users are encouraged to upgrade to this new version.

For source downloads of PHP 5.5.6 please visit our
downloads page:

http://www.php.net/downloads.php

Windows binaries can be found on:

http://windows.php.net/download/

The list of changes is recorded in the ChangeLog at:

http://www.php.net/ChangeLog-5.php#5.5.6

We would like to thank the contributors and the PHP community for making
this release available.

Regards,

Julien Pauli & David Soria Parra

--- End Message ---

Reply via email to