php-general Digest 26 Aug 2010 14:15:04 -0000 Issue 6911

Topics (messages 307679 through 307700):

Re: Web application architecture (subdomain vs. sub directory)
        307679 by: Per Jessen
        307680 by: Per Jessen
        307681 by: Peter Lind
        307682 by: Per Jessen
        307694 by: tedd
        307695 by: tedd
        307697 by: Bob McConnell

XML with PHP
        307683 by: user.domain.invalid
        307684 by: Michael Shadle
        307685 by: Michael Shadle
        307686 by: Sridhar Pandurangiah
        307687 by: Sridhar Pandurangiah
        307688 by: Sridhar Pandurangiah
        307689 by: Sridhar Pandurangiah
        307690 by: Sridhar Pandurangiah
        307691 by: Sridhar Pandurangiah
        307692 by: Sridhar Pandurangiah

Re: two questions on serverside validation
        307693 by: tedd

Variable in variable.
        307696 by: João Cândido de Souza Neto
        307698 by: Robert Cummings
        307699 by: João Cândido de Souza Neto

Does array_splice() fit for case ?
        307700 by: Alfredo Palhares

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 ---
Tim Martens wrote:

> Thanks for all your answers. To clarify my question, I'm looking for
> advice regarding how best to set up users for a web app, e.g.,
> username.myapp.com vs myapp.com/username and the pros and cons of
each.

Using username.myapp.com means defining that name in your DNS and having
a separate virtual host definition in your apache config. 

Using myapp.com/username means having one virtual host, and no extra DNS
records. 

One is not necessarily better or worse than the other - to me it's
mostly about presentation and I would go for the myapp.com/username
option.  This (in my mind) puts "username" a level lower than "myapp",
whereas username.myapp.com does the opposite. 


-- 
Per Jessen, Zürich (17.7°C)


--- End Message ---
--- Begin Message ---
Shreyas Agasthya wrote:

> I am not sure who the end-users are for your website but if you are
> concerned about scalability, I would definitely go for a sub-domain
> approach. Assuming you approach a CDN like Akamai and you want to
> offload the traffic to come from the cloud, it's lot easier for you to
> integrate with them and to maintain.
> 
> The subdirectory approach, whereas, is very cumbersome and  takes more
> work at your end to paraphrase the whole set-up should the needs
> change going forward.

The subdirectory approach is easily rewritten to an internal subdomain
structure. 



-- 
Per Jessen, Zürich (17.7°C)


--- End Message ---
--- Begin Message ---
On 26 August 2010 08:08, Per Jessen <p...@computer.org> wrote:
> Tim Martens wrote:
>
>> Thanks for all your answers. To clarify my question, I'm looking for
>> advice regarding how best to set up users for a web app, e.g.,
>> username.myapp.com vs myapp.com/username and the pros and cons of
> each.
>
> Using username.myapp.com means defining that name in your DNS and having
> a separate virtual host definition in your apache config.
>

While offtopic and nothing to do with PHP I think this should be
corrected: you can set a *.yourdomain rule which matches all
subdomains not explicitly set. So no, you do not need to define every
single name as a DNS record.

Regards
Peter

-- 
<hype>
WWW: http://plphp.dk / http://plind.dk
LinkedIn: http://www.linkedin.com/in/plind
BeWelcome/Couchsurfing: Fake51
Twitter: http://twitter.com/kafe15
</hype>

--- End Message ---
--- Begin Message ---
Peter Lind wrote:

> On 26 August 2010 08:08, Per Jessen <p...@computer.org> wrote:
>> Tim Martens wrote:
>>
>>> Thanks for all your answers. To clarify my question, I'm looking for
>>> advice regarding how best to set up users for a web app, e.g.,
>>> username.myapp.com vs myapp.com/username and the pros and cons of
>> each.
>>
>> Using username.myapp.com means defining that name in your DNS and
>> having a separate virtual host definition in your apache config.
>>
> 
> While offtopic and nothing to do with PHP I think this should be
> corrected: you can set a *.yourdomain rule which matches all
> subdomains not explicitly set. So no, you do not need to define every
> single name as a DNS record.

Good point. Not sure I would personally want to use wildcards, but it's
perfectly valid. 



-- 
Per Jessen, Zürich (17.7°C)


--- End Message ---
--- Begin Message ---
At 1:45 PM -0500 8/25/10, Tim Martens wrote:
Hi Everyone,

New to the list. Hello!

I'm in the customer discovery phase for a Health IT web application concept
I have. My programmer is new to web apps, but not to programming and is set
up with LAM(PHP). We're still debating weather to use a framework or to go
with Rasmus's "no framework framework" approach.

Language/Framework decisions aside... my main question is about subdomain (
customerx.appname.com vs subdirectory (appname.com/customerx/) models for
instances of individual customers' accounts.

It seems most people are opting for the former -- is this but a trebd? --
but I see flickr use the latter. The guys at Particletree (i.e., Wufoo)
wrote a blog post about it (
http://particletree.com/notebook/subdomains-development-sucks/) years ago to
which they still attest.

They say the subdirectory model is much easier and faster to develop and
deploy. We are developing locally on our macs and will be using
Mecurial/Bitbucket for CVS.

I'm really lost on this issue as all my searches turn up stuff on SEO/SEM.
Is one approach easier that the other? What about security and scalability
considerations? I would very much appreciate your opinions as to the pros
and cons of each approach.

As an aside, does anyone have some advice about rapid PHP deployment, i.e.,
pushing new features to production daily in micro iterations vs the typical
milestone approach? Are there any good tools for this? What about hosts?

Thanks all,

Tim

Tim:

My recommendations:

1. No framework. Learn one thing, namely what you want to do and not two (i.e., "what you want to do" and a "framework"). I did not know that Rasmus said that, but I listen to what he says.

2. Use directories. They are much simpler to use and easy to create/change/delete/scale/make-secure. -- SEO stuff does not apply here.

3. Investigate "Agile" development.

4. Host? Roll the dice like the rest of us.

Cheers,

tedd
--
-------
http://sperling.com/

--- End Message ---
--- Begin Message ---
At 4:45 PM -0500 8/25/10, Tim Martens wrote:
Thanks for all your answers. To clarify my question, I'm looking for advice
regarding how best to set up users for a web app, e.g., username.myapp.comvs
myapp.com/username and the pros and cons of each. All users will be using
essentially the same app that will have their data in their account. I can
see the logic of setting up subdomain for things like a universal login and,
say, metrics for example.

Is javascripting more difficult across subdomains? Is one approach beter in
terms of security? Essentially the entire app will be running on https.

Thanks again!

Tim


Tim:

That's a different question -- you should post another question rather than continue the old thread regarding something else.

Cheers,

tedd
--
-------
http://sperling.com/

--- End Message ---
--- Begin Message ---
From: tedd

> At 1:45 PM -0500 8/25/10, Tim Martens wrote:
>>Hi Everyone,
>>
>>New to the list. Hello!
>>
>>I'm in the customer discovery phase for a Health IT web application
concept
>>I have. My programmer is new to web apps, but not to programming and
is set
>>up with LAM(PHP). We're still debating weather to use a framework or
to go
>>with Rasmus's "no framework framework" approach.
>>
>>Language/Framework decisions aside... my main question is about
subdomain (
>>customerx.appname.com vs subdirectory (appname.com/customerx/) models
for
>>instances of individual customers' accounts.
>>
>>It seems most people are opting for the former -- is this but a trebd?
--
>>but I see flickr use the latter. The guys at Particletree (i.e.,
Wufoo)
>>wrote a blog post about it (
>>http://particletree.com/notebook/subdomains-development-sucks/) years
ago to
>>which they still attest.
>>
>>They say the subdirectory model is much easier and faster to develop
and
>>deploy. We are developing locally on our macs and will be using
>>Mecurial/Bitbucket for CVS.
>>
>>I'm really lost on this issue as all my searches turn up stuff on
SEO/SEM.
>>Is one approach easier that the other? What about security and
scalability
>>considerations? I would very much appreciate your opinions as to the
pros
>>and cons of each approach.
>>
>>As an aside, does anyone have some advice about rapid PHP deployment,
i.e.,
>>pushing new features to production daily in micro iterations vs the
typical
>>milestone approach? Are there any good tools for this? What about
hosts?
>>
>>Thanks all,
>>
>>Tim
>
> Tim:
> 
> My recommendations:
> 
> 1. No framework. Learn one thing, namely what you want to do and not 
> two (i.e., "what you want to do" and a "framework"). I did not know 
> that Rasmus said that, but I listen to what he says.
> 
> 2. Use directories. They are much simpler to use and easy to 
> create/change/delete/scale/make-secure. -- SEO stuff does not apply 
> here.
> 
> 3. Investigate "Agile" development.
> 
> 4. Host? Roll the dice like the rest of us.

Before you can select a hosting provider, define what you want. Are you
looking for a cage with power and network connections, a VM that you can
load up and manage, or a fully managed server environment? UPS or
generator? What about backup and failover? Do you need redundant network
connections? There is a wide range of options here that are not easy to
evaluate. We have used a variety of different hosts through the years as
our needs and requirements changed. Our current one is fully managed,
guarantees PCI compliance and is very expensive. But it is still less
than the FTE we would have to hire to do it all ourselves. We have more
than 100 client sites on that cluster of servers.

Depending on your size, it may be worth considering hiring a consultant
to walk you through this process the first time. It could save you a lot
of mistakes, time and money.

Bob McConnell

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

I am trying to read XML files (invoices) from a directory and display them to the visitor. Each XML file contains several invoices. The visitor then clicks on the XML file (invoices). My PHP snippet should open the xml file and locate the appropriate invoice and display the content.

I have managed to list the directory contents using the following PHP snippet. The function call below DisplayBill($MemberId, $FileName, $StyleSheet) should take the memberid (login), the xml file name which has been clicked and the stylesheet to be used.

I now have the following doubts for which I need clarifications

Architecturally is it necessary the DisplayBill should be a seperate php file or can it exist as a function in the same file as the code below?

Should the Invoices be displayed as a web form for me to capture the user click to retrieve the appropriate file and invoice so that I can display it to the user.

I intend to parse the XML file using XPath (at this stage I am not sure if php supports Xpath and XQuery!)

Any help would be appreciated

Best regards

Sridhar

-----------------------------------------------------------------------------

<?php
$BillLocation = "/home/cmi/Integration/xml_files";
$StyleSheet = "Bill.xsl";
$DirHandle = opendir($BillLocation);
echo "<table border=\"1\">";
echo "<tr>";
While (($FileName = readdir($DirHandle)) !== false)
{
        if ($FileName != "." && $FileName != "..")
        {
                if (strpos($FileName, "xml") !== false)
                {
                        $BillYear = substr($FileName, 0, 4);
                        $BillMonth = substr($FileName, 5, 2);
                        switch ($BillMonth)
                        {
                                case "01":
                                        $BillMonth = "January";
                                        break;
                                case "02":
                                        $BillMonth = "February";
                                        break;
                                case "03":
                                        $BillMonth = "March";
                                        break;
                                case "04":
                                        $BillMonth = "April";
                                        break;
                                case "05":
                                        $BillMonth = "May";
                                        break;
                                case "06":
                                        $BillMonth = "June";
                                        break;
                                case "07":
                                        $BillMonth = "July";
                                        break;
                                case "08":
                                        $BillMonth = "August";
                                        break;
                                case "09":
                                        $BillMonth = "September";
                                        break;
                                case "10":
                                        $BillMonth = "October";
                                        break;
                                case "11":
                                        $BillMonth = "November";
                                        break;
                                case "12":
                                        $BillMonth = "December";
                                        break;
                        }
echo "<td>" . "<a href='$FileName'>$BillMonth" . " " . "$BillYear</a>" . "</td>" . "\n";
                        echo "</tr>";
                        
                }
        }
}
echo "</table>";
closedir($DirHandle);

$result = DisplayBill($MemberId, $FileName, $StyleSheet);

--- End Message ---
--- Begin Message ---
On Thu, Aug 26, 2010 at 2:54 AM,  <u...@domain.invalid> wrote:
> Hi
>
> I am trying to read XML files (invoices) from a directory and display them
> to the visitor. Each XML file contains several invoices. The visitor then
> clicks on the XML file (invoices). My PHP snippet should open the xml file
> and locate the appropriate invoice and display the content.

a) first, your email address isn't correct

b) second, it looks like you intend on applying a stylesheet to get
your results. if you don't require XSL, you could look at just using
PHP's simplexml and/or XML DOM functions. it looks like you might just
be using the XSL to transform the XML anwyay; so from what it looks
like you -do not- need XSL in the mix.

c) you can put the PHP in any file you want

d) i believe xpath should work without any problems.

--- End Message ---
--- Begin Message ---
On Thu, Aug 26, 2010 at 3:10 AM, Sridhar Pandurangiah
<sridharpa...@gmail.com> wrote:
> Mike
>
> Thanks a ton for the quick response. I have updated the mail id on my email
> client (using Mozilla TB) and I did repost but your reply was quicker!
>
> Will try this out and post the results on this thread. Just waiting for
> someone to throw light on how to capture the "filename" that the user
> clicked. Should I display the directory listing as a form?

honestly, that's a little bit too "i'm writing code and solving all
your problems for you" for me... it's hard to concentrate, i have to
actually do the code, not read about it and try to figure it out from
a description :)

feel free to pastebin it, if i don't help you quick maybe someone else will.

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

I am trying to read XML files (invoices) from a directory and display
them to the visitor. Each XML file contains several invoices. The
visitor then clicks on the XML file (invoices). My PHP snippet should
open the xml file and locate the appropriate invoice and display the
content.

I have managed to list the directory contents using the following PHP
snippet. The function call below DisplayBill($MemberId, $FileName,
$StyleSheet) should take the memberid (login), the xml file name which
has been clicked and the stylesheet to be used.

I now have the following doubts for which I need clarifications

Architecturally is it necessary the DisplayBill should be a seperate php
file or can it exist as a function in the same file as the code below?

Should the Invoices be displayed as a web form for me to capture the
user click to retrieve the appropriate file and invoice so that I can
display it to the user.

I intend to parse the XML file using XPath (at this stage I am not sure
if php supports Xpath and XQuery!)

Any help would be appreciated

Best regards

Sridhar

-----------------------------------------------------------------------------

<?php
$BillLocation = "/home/cmi/Integration/xml_files";
$StyleSheet = "Bill.xsl";
$DirHandle = opendir($BillLocation);
echo "<table border=\"1\">";
echo "<tr>";
While (($FileName = readdir($DirHandle)) !== false)
{
        if ($FileName != "." && $FileName != "..")
        {
                if (strpos($FileName, "xml") !== false)
                {
                        $BillYear = substr($FileName, 0, 4);
                        $BillMonth = substr($FileName, 5, 2);
                        switch ($BillMonth)
                        {
                                case "01":
                                        $BillMonth = "January";
                                        break;
                                case "02":
                                        $BillMonth = "February";
                                        break;
                                case "03":
                                        $BillMonth = "March";
                                        break;
                                case "04":
                                        $BillMonth = "April";
                                        break;
                                case "05":
                                        $BillMonth = "May";
                                        break;
                                case "06":
                                        $BillMonth = "June";
                                        break;
                                case "07":
                                        $BillMonth = "July";
                                        break;
                                case "08":
                                        $BillMonth = "August";
                                        break;
                                case "09":
                                        $BillMonth = "September";
                                        break;
                                case "10":
                                        $BillMonth = "October";
                                        break;
                                case "11":
                                        $BillMonth = "November";
                                        break;
                                case "12":
                                        $BillMonth = "December";
                                        break;
                        }
                        echo "<td>" . "<a href='$FileName'>$BillMonth" . " " .
"$BillYear</a>" . "</td>" . "\n";
                        echo "</tr>";
                        
                }
        }
}
echo "</table>";
closedir($DirHandle);

$result = DisplayBill($MemberId, $FileName, $StyleSheet);

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

I am trying to read XML files (invoices) from a directory and display
them to the visitor. Each XML file contains several invoices. The
visitor then clicks on the XML file (invoices). My PHP snippet should
open the xml file and locate the appropriate invoice and display the
content.

I have managed to list the directory contents using the following PHP
snippet. The function call below DisplayBill($MemberId, $FileName,
$StyleSheet) should take the memberid (login), the xml file name which
has been clicked and the stylesheet to be used.

I now have the following doubts for which I need clarifications

Architecturally is it necessary the DisplayBill should be a seperate php
file or can it exist as a function in the same file as the code below?

Should the Invoices be displayed as a web form for me to capture the
user click to retrieve the appropriate file and invoice so that I can
display it to the user.

I intend to parse the XML file using XPath (at this stage I am not sure
if php supports Xpath and XQuery!)

Any help would be appreciated

Best regards

Sridhar

-----------------------------------------------------------------------------

<?php
$BillLocation = "/home/cmi/Integration/xml_files";
$StyleSheet = "Bill.xsl";
$DirHandle = opendir($BillLocation);
echo "<table border=\"1\">";
echo "<tr>";
While (($FileName = readdir($DirHandle)) !== false)
{
        if ($FileName != "." && $FileName != "..")
        {
                if (strpos($FileName, "xml") !== false)
                {
                        $BillYear = substr($FileName, 0, 4);
                        $BillMonth = substr($FileName, 5, 2);
                        switch ($BillMonth)
                        {
                                case "01":
                                        $BillMonth = "January";
                                        break;
                                case "02":
                                        $BillMonth = "February";
                                        break;
                                case "03":
                                        $BillMonth = "March";
                                        break;
                                case "04":
                                        $BillMonth = "April";
                                        break;
                                case "05":
                                        $BillMonth = "May";
                                        break;
                                case "06":
                                        $BillMonth = "June";
                                        break;
                                case "07":
                                        $BillMonth = "July";
                                        break;
                                case "08":
                                        $BillMonth = "August";
                                        break;
                                case "09":
                                        $BillMonth = "September";
                                        break;
                                case "10":
                                        $BillMonth = "October";
                                        break;
                                case "11":
                                        $BillMonth = "November";
                                        break;
                                case "12":
                                        $BillMonth = "December";
                                        break;
                        }
                        echo "<td>" . "<a href='$FileName'>$BillMonth" . " " .
"$BillYear</a>" . "</td>" . "\n";
                        echo "</tr>";
                        
                }
        }
}
echo "</table>";
closedir($DirHandle);

$result = DisplayBill($MemberId, $FileName, $StyleSheet);

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

I am trying to read XML files (invoices) from a directory and display
them to the visitor. Each XML file contains several invoices. The
visitor then clicks on the XML file (invoices). My PHP snippet should
open the xml file and locate the appropriate invoice and display the
content.

I have managed to list the directory contents using the following PHP
snippet. The function call below DisplayBill($MemberId, $FileName,
$StyleSheet) should take the memberid (login), the xml file name which
has been clicked and the stylesheet to be used.

I now have the following doubts for which I need clarifications

Architecturally is it necessary the DisplayBill should be a seperate php
file or can it exist as a function in the same file as the code below?

Should the Invoices be displayed as a web form for me to capture the
user click to retrieve the appropriate file and invoice so that I can
display it to the user.

I intend to parse the XML file using XPath (at this stage I am not sure
if php supports Xpath and XQuery!)

Any help would be appreciated

Best regards

Sridhar

-----------------------------------------------------------------------------

<?php
$BillLocation = "/home/cmi/Integration/xml_files";
$StyleSheet = "Bill.xsl";
$DirHandle = opendir($BillLocation);
echo "<table border=\"1\">";
echo "<tr>";
While (($FileName = readdir($DirHandle)) !== false)
{
        if ($FileName != "." && $FileName != "..")
        {
                if (strpos($FileName, "xml") !== false)
                {
                        $BillYear = substr($FileName, 0, 4);
                        $BillMonth = substr($FileName, 5, 2);
                        switch ($BillMonth)
                        {
                                case "01":
                                        $BillMonth = "January";
                                        break;
                                case "02":
                                        $BillMonth = "February";
                                        break;
                                case "03":
                                        $BillMonth = "March";
                                        break;
                                case "04":
                                        $BillMonth = "April";
                                        break;
                                case "05":
                                        $BillMonth = "May";
                                        break;
                                case "06":
                                        $BillMonth = "June";
                                        break;
                                case "07":
                                        $BillMonth = "July";
                                        break;
                                case "08":
                                        $BillMonth = "August";
                                        break;
                                case "09":
                                        $BillMonth = "September";
                                        break;
                                case "10":
                                        $BillMonth = "October";
                                        break;
                                case "11":
                                        $BillMonth = "November";
                                        break;
                                case "12":
                                        $BillMonth = "December";
                                        break;
                        }
                        echo "<td>" . "<a href='$FileName'>$BillMonth" . " " .
"$BillYear</a>" . "</td>" . "\n";
                        echo "</tr>";
                        
                }
        }
}
echo "</table>";
closedir($DirHandle);

$result = DisplayBill($MemberId, $FileName, $StyleSheet);

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

I guess my post was misunderstood. I was just trying to figure out if there is a better way other than displaying a form. That's the reason I posted my php snippet in my first post.

Thanks for the help.

Best regards

Sridhar

-------- Original Message --------
Subject: Re: [PHP] XML with PHP
From: mike...@gmail.com (Michael Shadle)
To:
Date: Thu Aug 26 2010 15:43:33 GMT+0530 (IST)

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

I guess my post was misunderstood. I was just trying to figure out if there is a better way other than displaying a form. That's the reason I posted my php snippet in my first post.

Thanks for the help.

Best regards

Sridhar

-------- Original Message --------
Subject: Re: [PHP] XML with PHP
From: mike...@gmail.com (Michael Shadle)
To:
Date: Thu Aug 26 2010 15:43:33 GMT+0530 (IST)

--- End Message ---
--- Begin Message ---
Mike

Thanks a ton for the quick response. I have updated the mail id on my email client (using Mozilla TB) and I did repost but your reply was quicker!

Will try this out and post the results on this thread. Just waiting for someone to throw light on how to capture the "filename" that the user clicked. Should I display the directory listing as a form?

Best regards

Sridhar

-------- Original Message --------
Subject: Re: [PHP] XML with PHP
From: mike...@gmail.com (Michael Shadle)
To:
Date: Thu Aug 26 2010 15:32:13 GMT+0530 (IST)

--- End Message ---
--- Begin Message ---
Mike

Thanks a ton for the quick response. I have updated the mail id on my email client (using Mozilla TB) and I did repost but your reply was quicker!

Will try this out and post the results on this thread. Just waiting for someone to throw light on how to capture the "filename" that the user clicked. Should I display the directory listing as a form?

Best regards

Sridhar

-------- Original Message --------
Subject: Re: [PHP] XML with PHP
From: mike...@gmail.com (Michael Shadle)
To:
Date: Thu Aug 26 2010 15:32:13 GMT+0530 (IST)


--- End Message ---
--- Begin Message ---
At 3:59 PM +0100 8/25/10, Ashley Sheridan wrote:

2.4 seconds doesn't seem so bad on 10 million iterations, but yes, it
does show that you should avoid it if it's really not necessary. Most
often I'll use that sort of syntax if I do something like this:

$greeting = "Hello $name, not seen you since $date";

which might be slower than:

$greeting = 'Hello ' . $name . ', not seen you since ' . $date;

but it is a whole lot neater and still gets syntax highlighting applied
in a decent IDE or editor.

Thanks,
Ash


Agreed.

Making things easy for both you and the programmer who follows is more important than cutting a few nanoseconds off compute time. After all, just displaying that information (i.e., echo) will take far more time and even vary more than that between monitors.

Cheers,

tedd

--
-------
http://sperling.com/

--- End Message ---
--- Begin Message ---
I know that in PHP I can use this:

$var1 = "text";
$var2 = '$var1';
4cho $$var2;

So it gives me "text".

My question is, is there a way of doing it with constant like this?

define("CONST", "text");
$test = "CONST";
echo $$test;

So it gives me "text".

Thanks in advance.
-- 
João Cândido de Souza Neto



--- End Message ---
--- Begin Message ---
On 10-08-26 09:54 AM, João Cândido de Souza Neto wrote:
I know that in PHP I can use this:

$var1 = "text";
$var2 = '$var1';
4cho $$var2;

So it gives me "text".

It would if you didn't have typos and the wrong quotes in the above :)

My question is, is there a way of doing it with constant like this?

define("CONST", "text");
$test = "CONST";
echo $$test;

So it gives me "text".

http://ca3.php.net/manual/en/function.constant.php

Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

--- End Message ---
--- Begin Message ---
Really cool...

Thanks and fogive me by my mistake. hehe

-- 
João Cândido de Souza Neto

"Robert Cummings" <rob...@interjinn.com> escreveu na mensagem 
news:4c76743a.2060...@interjinn.com...
> On 10-08-26 09:54 AM, João Cândido de Souza Neto wrote:
>> I know that in PHP I can use this:
>>
>> $var1 = "text";
>> $var2 = '$var1';
>> 4cho $$var2;
>>
>> So it gives me "text".
>
> It would if you didn't have typos and the wrong quotes in the above :)
>
>> My question is, is there a way of doing it with constant like this?
>>
>> define("CONST", "text");
>> $test = "CONST";
>> echo $$test;
>>
>> So it gives me "text".
>
> http://ca3.php.net/manual/en/function.constant.php
>
> Cheers,
> Rob.
> -- 
> E-Mail Disclaimer: Information contained in this message and any
> attached documents is considered confidential and legally protected.
> This message is intended solely for the addressee(s). Disclosure,
> copying, and distribution are prohibited unless authorized. 



--- End Message ---
--- Begin Message ---
Hello,

This is kinda a noob question, but that's what i am :)

I have a 2 dimensions array (the first dimension are "normal" keys ) and in
the second dimension haves custom arrays but they all have a comon key that
is *id.
*The array comes ascending ordered by the numbers of *id* .

When i receive this array i need to look for and array that haves the
*id*== 0, so i do a for  loop looking for it  and i unset this values
after
that.
But need i need that the unset array looks like this sub-array never existed
( eg. if the key that with id = 0  was "5", the "5" will the number "6" and
"6" the "7" and so on).
Here is the code:

<?php

// $data the name of the array

        //Look for the main email
        for ($i = 0; $i < count($data); $i++) {
             if ($data[$i]['id'] === 0) {
                 // It can't be empty
                 if (!empty($data[$i])) {
                     $this->email = $data[$i]['contact'];
                     $main_email_found = true;
                 }
                 unset($data[$i]);
             }
        }
?>

I have tree ways of doing this:

- Use a method that i that looks from duplicate entru based on the *id *key
as index and after and return the array ordered by this index.
- Adding a new entry to another array in this loop that not haves the
*id*== 0. and after that reverse the order
- Use the array_splice native function.

What do you recommend me ?
Sorry by the bad English.


-- 
Regards,
Alfredo Palhares

--- End Message ---

Reply via email to