php-general Digest 4 Sep 2012 06:17:03 -0000 Issue 7950
Topics (messages 318958 through 318978):
Re: load rtf file
318958 by: David OBrien
318971 by: Tedd Sperling
318972 by: Micky Hulse
318976 by: tamouse mailing lists
ksort by value
318959 by: John Taylor-Johnston
318960 by: Matijn Woudt
318962 by: John Taylor-Johnston
318963 by: John Taylor-Johnston
318964 by: Serge Fonville
318965 by: John Taylor-Johnston
318966 by: John Taylor-Johnston
318967 by: Serge Fonville
318968 by: Serge Fonville
318969 by: Stuart Dallas
318970 by: John Taylor-Johnston
mysql and php questions
318961 by: Littlefield, Tyler
templeting
318973 by: David McGlone
318974 by: David OBrien
318975 by: David McGlone
318977 by: tamouse mailing lists
318978 by: Louis Huppenbauer
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 ---
On Mon, Sep 3, 2012 at 12:56 PM, Matijn Woudt <tijn...@gmail.com> wrote:
> On Mon, Sep 3, 2012 at 5:24 PM, Tedd Sperling <t...@sperling.com> wrote:
> > On Sep 3, 2012, at 1:23 AM, John Taylor-Johnston
> <jt.johns...@usherbrooke.ca> wrote:
> >
> >> I have a big giant RTF file. I could convert it to plain text. BUT can
> PHP do it for me?
> >
> > Hell, even M$ can't do it!
> >
> > I have tons of old Word RFT files that were orphaned by the installation
> of a newer of M$ Word. The upgrade actually deleted older versions of Word
> and then would not open the older files because of security concerns (they
> were create by an older version, duh). It was a nightmare -- as a result, I
> lost years of business correspondence. Now I make z text version of every
> document I write.
> >
> > If I wanted to get those old files back, I will have to set up an older
> computer, reinstall the older version of Word and then transfer those
> files, convert them to text, and bring them back. That's a lot of work
> because I trusted M$ to respect older files, but they don't. In short,
> don't trust M$.
> >
> > Cheers,
> >
> > tedd
> >
>
> Either they don't have respect to the older files, or they just don't
> understand how the format works..
> The same goes for opening '97-'03 files in Word 2010 version,
> sometimes it's also all messed up.
>
> Just a side note tedd, couldn't you just open those RTF files with
> wordpad? IIRC it supports RTF and plain text (even in Win7)
>
> - Matijn
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
I found this
http://webcheatsheet.com/php/reading_the_clean_text_from_rtf.php
--- End Message ---
--- Begin Message ---
On Sep 3, 2012, at 12:56 PM, Matijn Woudt <tijn...@gmail.com> wrote
>
> Just a side note tedd, couldn't you just open those RTF files with
> wordpad? IIRC it supports RTF and plain text (even in Win7)
>
> - Matijn
Maybe if I was on a Windoze machine, but I'm on a Mac.
Cheers,
tedd
_____________________
t...@sperling.com
http://sperling.com
--- End Message ---
--- Begin Message ---
On Mon, Sep 3, 2012 at 3:52 PM, Tedd Sperling <t...@sperling.com> wrote:
> Maybe if I was on a Windoze machine, but I'm on a Mac.
What about TextEdit.app?
--- End Message ---
--- Begin Message ---
On Mon, Sep 3, 2012 at 6:04 PM, Micky Hulse <mickyhulse.li...@gmail.com> wrote:
> On Mon, Sep 3, 2012 at 3:52 PM, Tedd Sperling <t...@sperling.com> wrote:
>> Maybe if I was on a Windoze machine, but I'm on a Mac.
>
> What about TextEdit.app?
Or Open/Libre Office?
As for the OP, I know you can script Open/Libre Office with python to
do things like batch convert RTF to Text.
--- End Message ---
--- Begin Message ---
Hi,
<?php
...
$words = preg_split('/[[:space:]]+/',$mynewstring);
foreach ($words as $word) {
$freq[$word]++;
}
ksort($freq);
print_r ($freq);
?>
If I have my terminology right, ksort($freq) sorts the array by the key.
And that works fine.
But I would also like to sort by value to see which words are more frequent.
There is no |ascending/descending option to ksort?|
Thanks,
John
Array
(
[] => 1
[a] => 165
[about] => 4
[academy] => 4
[accident] => 3
[accidental] => 1
[accused] => 1
[achieve] => 1
[across] => 1
[act] => 3
[addition] => 1
[address] => 1
[adult] => 3
[advise] => 2
[advised] => 1
[advising] => 2
[advisory] => 4
[after] => 2
[aged] => 1
[aggravated] => 1
[airport] => 4
[alarm] => 2
[alcohol] => 5
[alert] => 1
[all] => 2
[allegedly] => 2
[allow] => 1
[along] => 2
[also] => 14
[altercation] => 2
[am] => 16
--- End Message ---
--- Begin Message ---
On Mon, Sep 3, 2012 at 8:33 PM, John Taylor-Johnston
<jt.johns...@usherbrooke.ca> wrote:
> Hi,
>
> <?php
> ...
> $words = preg_split('/[[:space:]]+/',$mynewstring);
>
> foreach ($words as $word) {
> $freq[$word]++;
> }
>
> ksort($freq);
> print_r ($freq);
> ?>
>
> If I have my terminology right, ksort($freq) sorts the array by the key. And
> that works fine.
> But I would also like to sort by value to see which words are more frequent.
> There is no |ascending/descending option to ksort?|
>
> Thanks,
> John
ksort sorts by key, if you want by value, look at sort.
As to asc/desc sort, they just have a different name. ksort and sort
are asc, krsort and rsort are desc equivalents.
- Matijn
--- End Message ---
--- Begin Message ---
<?php
...
$words = preg_split('/[[:space:]]+/',$mynewstring);
foreach ($words as $word) {
$freq[$word]++;
}
ksort($freq);
print_r ($freq);
?>
ksort($freq) sorts the array by the key. And that works fine.
But I would also like to sort by value to see which words are more frequent.
There is no |ascending/descending option to ksort?|
ksort sorts by key, if you want by value, look at sort.
As to asc/desc sort, they just have a different name. ksort and sort
are asc, krsort and rsort are desc equivalents.
- Matijn
Sort does not work seamlessly.
--- End Message ---
--- Begin Message ---
<?php
...
$words = preg_split('/[[:space:]]+/',$mynewstring);
foreach ($words as $word) {
$freq[$word]++;
}
ksort($freq);
print_r ($freq);
?>
ksort($freq) sorts the array by the key. And that works fine.
But I would also like to sort by value to see which words are more frequent.
There is no |ascending/descending option to ksort?|
ksort sorts by key, if you want by value, look at sort.
As to asc/desc sort, they just have a different name. ksort and sort
are asc, krsort and rsort are desc equivalents.
- Matijn
I'm fuzzy when it comes to arrays. I never get what I want right.
Sort does not work seamlessly. I have my key and
sort($freq);
print_r ($freq);
looks like:
Array
(
...
[1000] => 172
[1001] => 176
[1002] => 179
[1003] => 441
)
This is what I want:
Array
(
...
[and] => 172
[of] => 176
[to] => 179
[the] => 441
)
--- End Message ---
--- Begin Message ---
Hi,
Have you looked at http://php.net/manual/en/array.sorting.php?
Kind regards/met vriendelijke groet,
Serge Fonville
http://www.sergefonville.nl
Convince Microsoft!
They need to add TRUNCATE PARTITION in SQL Server
https://connect.microsoft.com/SQLServer/feedback/details/417926/truncate-partition-of-partitioned-table
2012/9/3 John Taylor-Johnston <jt.johns...@usherbrooke.ca>
>
> <?php
>>> ...
>>> $words = preg_split('/[[:space:]]+/',$**mynewstring);
>>>
>>> foreach ($words as $word) {
>>> $freq[$word]++;
>>> }
>>>
>>> ksort($freq);
>>> print_r ($freq);
>>> ?>
>>>
>>> ksort($freq) sorts the array by the key. And that works fine.
>>> But I would also like to sort by value to see which words are more
>>> frequent.
>>> There is no |ascending/descending option to ksort?|
>>>
>> ksort sorts by key, if you want by value, look at sort.
>>
>> As to asc/desc sort, they just have a different name. ksort and sort
>> are asc, krsort and rsort are desc equivalents.
>> - Matijn
>>
> I'm fuzzy when it comes to arrays. I never get what I want right.
>
> Sort does not work seamlessly. I have my key and
>
> sort($freq);
> print_r ($freq);
>
> looks like:
>
> Array
> (
> ...
> [1000] => 172
> [1001] => 176
> [1002] => 179
> [1003] => 441
> )
>
> This is what I want:
>
> Array
> (
> ...
> [and] => 172
> [of] => 176
> [to] => 179
> [the] => 441
>
> )
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--- End Message ---
--- Begin Message ---
Serge Fonville wrote:
Have you looked at http://php.net/manual/en/array.sorting.php?
2012/9/3 John Taylor-Johnston <jt.johns...@usherbrooke.ca
<mailto:jt.johns...@usherbrooke.ca>>
<?php
...
$words = preg_split('/[[:space:]]+/',$mynewstring);
foreach ($words as $word) {
$freq[$word]++;
}
ksort($freq);
print_r ($freq);
?>
ksort($freq) sorts the array by the key. And that works fine.
But I would also like to sort by value to see which words
are more frequent.
There is no |ascending/descending option to ksort?|
ksort sorts by key, if you want by value, look at sort.
As to asc/desc sort, they just have a different name. ksort
and sort
are asc, krsort and rsort are desc equivalents.
- Matijn
I'm fuzzy when it comes to arrays. I never get what I want right.
Sort does not work seamlessly. I have my key and
sort($freq);
print_r ($freq);
looks like:
Array
(
...
[1000] => 172
[1001] => 176
[1002] => 179
[1003] => 441
)
This is what I want:
Array
(
...
[and] => 172
[of] => 176
[to] => 179
[the] => 441
)
I'm beginning to think I should plug this into a MySQL table, where I
would be at home.
But right now, I'll be stubborn and go read
http://php.net/manual/en/array.sorting.php.
Merci Serge,
John
--- End Message ---
--- Begin Message ---
<?php
...
$words = preg_split('/[[:space:]]+/',$mynewstring);
foreach ($words as $word) {
$freq[$word]++;
}
ksort($freq);
print_r ($freq);
?>
Sort does not work seamlessly. I have my key and
sort($freq);
print_r ($freq);
looks like:
Array
(
...
[1000] => 172
[1001] => 176
[1002] => 179
[1003] => 441
)
This is what I want:
Array
(
...
[and] => 172
[of] => 176
[to] => 179
[the] => 441
)
http://php.net/manual/en/array.sorting.php is pretty clear. But my
problem is that sort ($freq) destroyed my key.
--- End Message ---
--- Begin Message ---
Sort does not maintain the association between key and value. Use asort to
sort on value while maintaining the key.
Kind regards/met vriendelijke groet,
Serge Fonville
http://www.sergefonville.nl
Convince Microsoft!
They need to add TRUNCATE PARTITION in SQL Server
https://connect.microsoft.com/SQLServer/feedback/details/417926/truncate-partition-of-partitioned-table
2012/9/3 John Taylor-Johnston <jt.johns...@usherbrooke.ca>
>
> <?php
>>>> ...
>>>> $words = preg_split('/[[:space:]]+/',$mynewstring);
>>>>
>>>> foreach ($words as $word) {
>>>> $freq[$word]++;
>>>> }
>>>>
>>>> ksort($freq);
>>>> print_r ($freq);
>>>> ?>
>>>>
>>>
>>> Sort does not work seamlessly. I have my key and
>> sort($freq);
>> print_r ($freq);
>> looks like:
>>
>> Array
>> (
>> ...
>> [1000] => 172
>> [1001] => 176
>> [1002] => 179
>> [1003] => 441
>> )
>>
>> This is what I want:
>>
>> Array
>> (
>> ...
>> [and] => 172
>> [of] => 176
>> [to] => 179
>> [the] => 441
>>
>> )
>>
>
> http://php.net/manual/en/array.sorting.php is pretty clear. But my
> problem is that sort ($freq) destroyed my key.
>
>
>
--- End Message ---
--- Begin Message ---
If you want to perform a count on all the unique values (in SQL Terms a
group by and a count) use
http://php.net/manual/en/function.array-count-values.php instead.
Kind regards/met vriendelijke groet,
Serge Fonville
http://www.sergefonville.nl
Convince Microsoft!
They need to add TRUNCATE PARTITION in SQL Server
https://connect.microsoft.com/SQLServer/feedback/details/417926/truncate-partition-of-partitioned-table
2012/9/3 Serge Fonville <serge.fonvi...@gmail.com>
> Sort does not maintain the association between key and value. Use asort to
> sort on value while maintaining the key.
>
> Kind regards/met vriendelijke groet,
>
> Serge Fonville
>
> http://www.sergefonville.nl
>
> Convince Microsoft!
> They need to add TRUNCATE PARTITION in SQL Server
>
> https://connect.microsoft.com/SQLServer/feedback/details/417926/truncate-partition-of-partitioned-table
>
>
>
> 2012/9/3 John Taylor-Johnston <jt.johns...@usherbrooke.ca>
>
>>
>> <?php
>>>>> ...
>>>>> $words = preg_split('/[[:space:]]+/',$mynewstring);
>>>>>
>>>>> foreach ($words as $word) {
>>>>> $freq[$word]++;
>>>>> }
>>>>>
>>>>> ksort($freq);
>>>>> print_r ($freq);
>>>>> ?>
>>>>>
>>>>
>>>> Sort does not work seamlessly. I have my key and
>>> sort($freq);
>>> print_r ($freq);
>>> looks like:
>>>
>>> Array
>>> (
>>> ...
>>> [1000] => 172
>>> [1001] => 176
>>> [1002] => 179
>>> [1003] => 441
>>> )
>>>
>>> This is what I want:
>>>
>>> Array
>>> (
>>> ...
>>> [and] => 172
>>> [of] => 176
>>> [to] => 179
>>> [the] => 441
>>>
>>> )
>>>
>>
>> http://php.net/manual/en/array.sorting.php is pretty clear. But my
>> problem is that sort ($freq) destroyed my key.
>>
>>
>>
>
--- End Message ---
--- Begin Message ---
On 3 Sep 2012, at 22:55, John Taylor-Johnston <jt.johns...@usherbrooke.ca>
wrote:
> http://php.net/manual/en/array.sorting.php is pretty clear. But my problem is
> that sort ($freq) destroyed my key.
Did you actually read it? There's a table on that page that summarises exactly
what each sorting function does, with a column for whether they "maintain key
association."
In this case you want http://php.net/asort
-Stuart
--
Stuart Dallas
3ft9 Ltd
http://3ft9.com/
--- End Message ---
--- Begin Message ---
That works, thanks.
I think I'll put this into MySQL eventually. "sort by" key would do it
better, and I will need to more.
Serge Fonville wrote:
Sort does not maintain the association between key and value. Use
asort to sort on value while maintaining the key.
Kind regards/met vriendelijke groet,
Serge Fonville
http://www.sergefonville.nl
Convince Microsoft!
They need to add TRUNCATE PARTITION in SQL Server
https://connect.microsoft.com/SQLServer/feedback/details/417926/truncate-partition-of-partitioned-table
2012/9/3 John Taylor-Johnston <jt.johns...@usherbrooke.ca
<mailto:jt.johns...@usherbrooke.ca>>
<?php
...
$words = preg_split('/[[:space:]]+/',$mynewstring);
foreach ($words as $word) {
$freq[$word]++;
}
ksort($freq);
print_r ($freq);
?>
Sort does not work seamlessly. I have my key and
sort($freq);
print_r ($freq);
looks like:
Array
(
...
[1000] => 172
[1001] => 176
[1002] => 179
[1003] => 441
)
This is what I want:
Array
(
...
[and] => 172
[of] => 176
[to] => 179
[the] => 441
)
http://php.net/manual/en/array.sorting.php is pretty clear. But my
problem is that sort ($freq) destroyed my key.
--- End Message ---
--- Begin Message ---
Hello all:
I had a few questions.
First, I'm using php-fastcgi with nginx for my primary web server. I was
wondering what sorts of optimizations exist to make this process a lot
faster.
Second, I'm setting up a custom application, and it contains an
authentication module for login/registration. In doing this, I
discovered PDO (I used to just use the mysql_* functions). According to
google, it's easier to prevent mysql injection attacks with PDO, so I
dove in.
Before, I was using $pdo->exec("...");, but I read that I need to call
quote on the variables I'm passing in. It looks like that all quote does
is just add '...' on the variables, but I could be wrong.
So, here's my questions:
First, I know that prepared statements are immune to mysql injection
attacks, if I just use the variables with placeholders in the
statements. I know that caching these means that the optimization does
not have to be done every time, but is this the most efficient method
for adding a single user for registration? Or would a basic query be better.
Also, I had the idea of building up common queries and cacheing them,
but this isn't really possible since each php script (as far as I'm
aware) gets it's own process or environment. If I can build the prepared
statements and cache them, it seems like things would be a lot quicker.
Is this something commonly done?
--
Take care,
Ty
http://tds-solutions.net
The aspen project: a barebones light-weight mud engine:
http://code.google.com/p/aspenmud
He that will not reason is a bigot; he that cannot reason is a fool; he that
dares not reason is a slave.
--- End Message ---
--- Begin Message ---
Does anyone use any templeting system for any projects? If so what would
anyone recommend? I looked at Code Ignitor, but it seems the templeting system
is optional and left out by default.
--
Regards
David M.
--- End Message ---
--- Begin Message ---
On Sep 3, 2012 9:15 PM, "David McGlone" <da...@dmcentral.net> wrote:
>
> Does anyone use any templeting system for any projects? If so what would
> anyone recommend? I looked at Code Ignitor, but it seems the templeting
system
> is optional and left out by default.
>
> --
> Regards
> David M.
I use smarty
--- End Message ---
--- Begin Message ---
On Monday, September 03, 2012 09:45:23 PM David OBrien wrote:
> On Sep 3, 2012 9:15 PM, "David McGlone" <da...@dmcentral.net> wrote:
> > Does anyone use any templeting system for any projects? If so what would
> > anyone recommend? I looked at Code Ignitor, but it seems the templeting
>
> system is optional and left out by default.
> I use smarty
I've used smarty in the past and was thinking about that, but PEAR is absolete
anymore and I don't really know of a good replacement. :-/
--
Regards
David M.
--- End Message ---
--- Begin Message ---
On Mon, Sep 3, 2012 at 8:49 PM, David McGlone <da...@dmcentral.net> wrote:
> On Monday, September 03, 2012 09:45:23 PM David OBrien wrote:
>> On Sep 3, 2012 9:15 PM, "David McGlone" <da...@dmcentral.net> wrote:
>> > Does anyone use any templeting system for any projects? If so what would
>> > anyone recommend? I looked at Code Ignitor, but it seems the templeting
>>
>> system is optional and left out by default.
>
>> I use smarty
>
> I've used smarty in the past and was thinking about that, but PEAR is absolete
> anymore and I don't really know of a good replacement. :-/
I use Smarty as well, but I've never used it from PEAR. I just use the
version downloadable from http://www.smarty.net
--- End Message ---
--- Begin Message ---
2012/9/4 tamouse mailing lists <tamouse.li...@gmail.com>
> On Mon, Sep 3, 2012 at 8:49 PM, David McGlone <da...@dmcentral.net> wrote:
> > On Monday, September 03, 2012 09:45:23 PM David OBrien wrote:
> >> On Sep 3, 2012 9:15 PM, "David McGlone" <da...@dmcentral.net> wrote:
> >> > Does anyone use any templeting system for any projects? If so what
> would
> >> > anyone recommend? I looked at Code Ignitor, but it seems the
> templeting
> >>
> >> system is optional and left out by default.
> >
> >> I use smarty
> >
> > I've used smarty in the past and was thinking about that, but PEAR is
> absolete
> > anymore and I don't really know of a good replacement. :-/
>
> I use Smarty as well, but I've never used it from PEAR. I just use the
> version downloadable from http://www.smarty.net
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
I'm mostly working with twig, a symfony2 framework component.
I especially like it's template inheritance and the (in my opinion) very
clear syntax.
http://twig.sensiolabs.org/
--- End Message ---