php-general Digest 13 May 2010 21:13:07 -0000 Issue 6742
Topics (messages 305140 through 305155):
Re: stristr query trouble
305140 by: Lawrance Shepstone
305141 by: Warren Windvogel
305142 by: Peter Lind
305143 by: Lawrance Shepstone
Parse question
305144 by: Ron Piggott
305145 by: Cemal Eker
305146 by: Lawrance Shepstone
create tree from arrays
305147 by: shahrzad khorrami
305148 by: Richard Quadling
305149 by: Richard Quadling
305150 by: shahrzad khorrami
305151 by: shahrzad khorrami
305152 by: Richard Quadling
Re: function/class to convert IDN (Puny-Code)?
305153 by: tedd
Re: GD - import a PNG image and make transparant
305154 by: tedd
opening a link in a new window
305155 by: David Mehler
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 ---
-----Original Message-----
From: Ron Piggott [mailto:ron....@actsministries.org]
Sent: 13 May 2010 06:02 AM
To: PHP General
Subject: [PHP] stristr query trouble
I am not understanding why 'true' isn't the result of this syntax because
$subjects equals:
$subjects = "Delivery Status Notification(Failure)";
Here is my syntax:
if ( stristr( $subjects, "Delivery Status Notifcation(Failure)" ) ) {
$TIRSFlag = true;
echo "true";
}
_________________________________________________________________________
You have misspelled 'Notification' in your comparison ...
You should probably use Regular Expressions for this kind of thing.
Best of luck,
Lawrance
--- End Message ---
--- Begin Message ---
Ron Piggott wrote:
$subjects = "Delivery Status Notification(Failure)";
Here is my syntax:
if ( stristr( $subjects, "Delivery Status Notifcation(Failure)" ) ) {
Notification is misspelled. Next time copy and paste the comparison
string or use regular expressions to be more safe.
Kind regards
Warren
--
Developer
The University of the Witwatersrand
Email: warren.windvo...@wits.ac.za
Gmail: wwindvo...@gmail.com
MSN: wwindvo...@hotmail.com
Skype: wwindvogel
Tel: +27 11 717 7184
Cell: +27 73 264 6700
Fax2Email: 0862950483
--- End Message ---
--- Begin Message ---
On 13 May 2010 10:08, Lawrance Shepstone <p...@digitalvoice.co.za> wrote:
> -----Original Message-----
> From: Ron Piggott [mailto:ron....@actsministries.org]
> Sent: 13 May 2010 06:02 AM
> To: PHP General
> Subject: [PHP] stristr query trouble
>
> I am not understanding why 'true' isn't the result of this syntax because
> $subjects equals:
>
> $subjects = "Delivery Status Notification(Failure)";
>
> Here is my syntax:
>
> if ( stristr( $subjects, "Delivery Status Notifcation(Failure)" ) ) {
> $TIRSFlag = true;
> echo "true";
> }
>
> _________________________________________________________________________
>
> You have misspelled 'Notification' in your comparison ...
>
> You should probably use Regular Expressions for this kind of thing.
>
Regexes are best used when what you need to match is dynamic or in a
dynamic string. When you know what the output will be and can match
it, the str* functions are much better as they are much more
efficient.
Regards
Peter
--
<hype>
WWW: http://plphp.dk / http://plind.dk
LinkedIn: http://www.linkedin.com/in/plind
Flickr: http://www.flickr.com/photos/fake51
BeWelcome: Fake51
Couchsurfing: Fake51
</hype>
--- End Message ---
--- Begin Message ---
On 13 May 2010 10:08, Lawrance Shepstone <p...@digitalvoice.co.za> wrote:
> -----Original Message-----
> From: Ron Piggott [mailto:ron....@actsministries.org]
> Sent: 13 May 2010 06:02 AM
> To: PHP General
> Subject: [PHP] stristr query trouble
>
> I am not understanding why 'true' isn't the result of this syntax because
> $subjects equals:
>
> $subjects = "Delivery Status Notification(Failure)";
>
> Here is my syntax:
>
> if ( stristr( $subjects, "Delivery Status Notifcation(Failure)" ) ) {
> $TIRSFlag = true;
> echo "true";
> }
>
> _________________________________________________________________________
>
> You have misspelled 'Notification' in your comparison ...
>
> You should probably use Regular Expressions for this kind of thing.
>
Regexes are best used when what you need to match is dynamic or in a
dynamic string. When you know what the output will be and can match
it, the str* functions are much better as they are much more
efficient.
Regards
Peter
____________________________________________________________________________
Agreed ;-)
--- End Message ---
--- Begin Message ---
If $message_body contains:
$message_body="You are subscribed using u...@domain. To update";
How do I capture just the e-mail address?
Ron
--- End Message ---
--- Begin Message ---
Check this out. http://www.regular-expressions.info/email.html
---
“Talk is cheap. Show me the code” - Linus Torvalds
On Thu, May 13, 2010 at 7:34 AM, Ron Piggott <ron.pigg...@actsministries.org
> wrote:
>
> If $message_body contains:
>
> $message_body="You are subscribed using u...@domain. To update";
>
> How do I capture just the e-mail address?
>
> Ron
>
>
--- End Message ---
--- Begin Message ---
-----Original Message-----
From: Ron Piggott [mailto:ron.pigg...@actsministries.org]
Sent: 13 May 2010 06:34 AM
To: PHP General
Subject: [PHP] Parse question
If $message_body contains:
$message_body="You are subscribed using u...@domain. To update";
How do I capture just the e-mail address?
Ron
______________________________________________________________________________
Regular Expressions ... They're great at this sort of thing!
I'd suggest starting here:
http://www.regular-expressions.info/email.html
Then take a look at the PHP regular expression manual:
http://www.php.net/manual/en/book.pcre.php
Have fun!
Lawrance
--- End Message ---
--- Begin Message ---
hi all,
I want to create an array from another array to create json file in my
format and pass it to a js library....ok.
I just know that I have to use recursive function... but how? it's hard for
me to create the new array..
main array:
Array
(
[0] => Array
(
[nid] => 1
[parentID] => 0
[text] => Dashboard
[cls] => x-btn-icon
[icon] => lib/extjs/resources/images/default/icon/Dashboard.png
[singleClickExpand] => 1
[leaf] => 0
[id] => Dashboard
)
[1] => Array
(
[nid] => 2
[parentID] => 1
[text] => Dashboard
[cls] => firstExpanded
[icon] => lib/extjs/resources/images/default/tree/s.gif
[singleClickExpand] => 1
[leaf] => 0
[id] =>
)
[2] => Array
(
[nid] => 3
[parentID] => 2
[text] => Dashboard
[cls] => x-btn-icon
[icon] => lib/extjs/resources/images/default/tree/s.gif
[singleClickExpand] => 1
[leaf] => 1
[id] => dashboard
)
...........
---------------------- The array I want to create: ----------------
[0] => Array
(
[nid] => 1
[parentID] => 0
[text] => Dashboard
[cls] => x-btn-icon
[icon] => lib/extjs/resources/images/default/icon/Dashboard.png
[singleClickExpand] => 1
[leaf] => 0
[id] => Dashboard
[children] => Array(
[0] => Array
(
[nid] => 2
[parentID] => 1
[text] => Dashboard
[cls] => firstExpanded
[icon] =>
lib/extjs/resources/images/default/tree/s.gif
[singleClickExpand] => 1
[leaf] => 0
[id] =>
[children] => Array(
[0] => Array
(
[nid] => 3
[parentID] => 2
[text] => Dashboard
[cls] => x-btn-icon
[icon] =>
lib/extjs/resources/images/default/tree/s.gif
[singleClickExpand] =>
1
[leaf] => 1
[id] => dashboard
)
)
)
)
)
.........
wow!
it means that by nid and parentID, I'll notice where I must add children
item to array...
Thanks,
Shahrzad
--- End Message ---
--- Begin Message ---
On 13 May 2010 09:51, shahrzad khorrami <shahrzad.khorr...@gmail.com> wrote:
> hi all,
>
> I want to create an array from another array to create json file in my
> format and pass it to a js library....ok.
> I just know that I have to use recursive function... but how? it's hard for
> me to create the new array..
Assuming that nid = 1 / parentID = 0 is the root.
<?php
$Relationships = array();
foreach($Data as $ID => $Row)
{
$Relationships[$ID] = $Row['nid'];
}
foreach($Data as $ID => &$Row)
{
if (0 != $Row['parentID'])
{
$Data[array_search($Row['parentID'],
$Relationships)]['children'][] = &$Row;
}
}
print_r($Data[0]);
?>
outputs ...
Array
(
[nid] => 1
[parentID] => 0
[text] => Dashboard
[cls] => x-btn-icon
[icon] => lib/extjs/resources/images/default/icon/Dashboard.png
[singleClickExpand] => 1
[leaf] => 0
[id] => Dashboard
[children] => Array
(
[0] => Array
(
[nid] => 2
[parentID] => 1
[text] => Dashboard
[cls] => firstExpanded
[icon] => lib/extjs/resources/images/default/tree/s.gif
[singleClickExpand] => 1
[leaf] => 0
[id] =>
[children] => Array
(
[0] => Array
(
[nid] => 3
[parentID] => 2
[text] => Dashboard
[cls] => x-btn-icon
[icon] =>
lib/extjs/resources/images/default/tree/s.gif
[singleClickExpand] => 1
[leaf] => 1
[id] => dashboard
)
)
)
)
)
--
-----
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling
--- End Message ---
--- Begin Message ---
On 13 May 2010 11:09, Richard Quadling <rquadl...@googlemail.com> wrote:
> On 13 May 2010 09:51, shahrzad khorrami <shahrzad.khorr...@gmail.com> wrote:
>> hi all,
>>
>> I want to create an array from another array to create json file in my
>> format and pass it to a js library....ok.
>> I just know that I have to use recursive function... but how? it's hard for
>> me to create the new array..
>
> Assuming that nid = 1 / parentID = 0 is the root.
>
> <?php
> $Relationships = array();
> foreach($Data as $ID => $Row)
> {
> $Relationships[$ID] = $Row['nid'];
> }
>
> foreach($Data as $ID => &$Row)
> {
> if (0 != $Row['parentID'])
> {
> $Data[array_search($Row['parentID'],
> $Relationships)]['children'][] = &$Row;
> }
> }
>
> print_r($Data[0]);
> ?>
>
> outputs ...
>
> Array
> (
> [nid] => 1
> [parentID] => 0
> [text] => Dashboard
> [cls] => x-btn-icon
> [icon] => lib/extjs/resources/images/default/icon/Dashboard.png
> [singleClickExpand] => 1
> [leaf] => 0
> [id] => Dashboard
> [children] => Array
> (
> [0] => Array
> (
> [nid] => 2
> [parentID] => 1
> [text] => Dashboard
> [cls] => firstExpanded
> [icon] => lib/extjs/resources/images/default/tree/s.gif
> [singleClickExpand] => 1
> [leaf] => 0
> [id] =>
> [children] => Array
> (
> [0] => Array
> (
> [nid] => 3
> [parentID] => 2
> [text] => Dashboard
> [cls] => x-btn-icon
> [icon] =>
> lib/extjs/resources/images/default/tree/s.gif
> [singleClickExpand] => 1
> [leaf] => 1
> [id] => dashboard
> )
>
> )
>
> )
>
> )
>
> )
>
>
>
> --
> -----
> Richard Quadling
> "Standing on the shoulders of some very clever giants!"
> EE : http://www.experts-exchange.com/M_248814.html
> EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
> Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
> ZOPA : http://uk.zopa.com/member/RQuadling
>
If the array index was the same as nid this would be ...
<?php
foreach($Data as $ID => &$Row)
{
if (0 != $Row['parentID'])
{
$Data[$Row['parentID']]['children'][] = &$Row;
}
}
print_r($Data[1]);
?>
--
-----
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling
--- End Message ---
--- Begin Message ---
Thanks Rechard :) I'm testing it... merccc
--- End Message ---
--- Begin Message ---
Dear Richard,
we have more than one parentID with value 0 in main array, your
code is so good but show me just the children of first parentID 0.
:)
Thanks,
Shahrzad
--- End Message ---
--- Begin Message ---
On 13 May 2010 11:42, shahrzad khorrami <shahrzad.khorr...@gmail.com> wrote:
>
> Dear Richard,
> we have more than one parentID with value 0 in main array, your
> code is so good but show me just the children of first parentID 0.
>
> :)
>
> Thanks,
> Shahrzad
>
print_r($Data[0]['children']);
maybe.
--
-----
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling
--- End Message ---
--- Begin Message ---
At 4:51 AM +0200 5/13/10, Michelle Konzack wrote:
Hello,
while reading RFC3490 (plus 3454/3491/3492) and before I am ongoing to
reinvent the wheel here the question:
Does someone HAVE or know a function/class which
does the IDN conversion "toASCII" and "toUNICODE"?
Note: The C Source-Code is included in RFC3492 and
can more or less easily converted to PHP.
Thanks, Greetings and nice Day/Evening
Michelle Konzack
Systemadministrator
You might try:
http://josefsson.org/idn.php
I use:
http://mct.verisign-grs.com/index.shtml
Cheers,
tedd
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
--- End Message ---
--- Begin Message ---
At 6:40 PM -0500 5/12/10, Karl DeSaulniers wrote:
Hi Alex,
I have a php file I made just a few months ago.
It takes a gif, jpeg or png of any size and sizes it proportionately
to a specified size and then outputs a png.
If the image is a transparent png or transparent gif, it will still
hold the transparency.
This is just a test page and it tested ok for me, but it is my first
one. I also tested it on PHP 5. Dont know about compatibility to
older versions.
Knowing that, here you go.
http://designdrumm.com/upload_images_test.php.zip
HTH,
Karl
Bad link.
Cheers,
tedd
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
--- End Message ---
--- Begin Message ---
Hello,
I want to open an external link in a new window, i know i can do this
with xhtml, but only with the transitional dtd, which i'm not using. I
was wondering if php could pull this off?
Thanks.
Dave.
--- End Message ---