php-windows Digest 19 May 2002 10:15:20 -0000 Issue 1151
Topics (messages 13858 through 13859):
Re: ASP and PHP
13858 by: Luis Ferro
Re: How to get all combinations
13859 by: Tomator
Administrivia:
To subscribe to the digest, e-mail:
[EMAIL PROTECTED]
To unsubscribe from the digest, e-mail:
[EMAIL PROTECTED]
To post to the list, e-mail:
[EMAIL PROTECTED]
----------------------------------------------------------------------
--- Begin Message ---
In a purelly personnal taste, i prefer PHP over ASP because the syntax
is C like, which makes it easier to programm in both client side
(Javascript) and server side (php). Specially because VBScript isn't a
option for client side programming (isn't a standard).
BUT i program in both and like to do it... specially if a client is
paying for the job!
Cheers...
Luis Ferro
TelaDigital
Benjamin Walling wrote:
>I'm currently switching from ASP to PHP, so I'm not an MS zealot. I did
>want to clarify some of your statements.
>
>
>"Court Shrock" <[EMAIL PROTECTED]> wrote in message
>[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
>
>
>>ASP can't do associative arrays
>>
>>
>like a hash table? ASP has the dictionary object.
>
The dictionary object is a component and more... isn't thread safe and
thrus can't be used as an application object. But your point is valid...
It has a hash table... of sorts...
>>ASP can't do serious string manipulation
>>
>>
>ASP has Regular expressions
>
>
It uses a component for them (i think... never did heavy string
manipulation...).
>>ASP cannot short-circuit a boolean expression
>>
>>
>?costing you milliseconds?
>
Costing the evaluation of another expression which can cost a lot of
time... depending on the case... It is specially bad if it is inside a loop.
>>ASP database connection is very cryptic (because of COM) and lengthy to
>>perform the simplist of queries
>>
>>
>You're doing it wrong, then. It doesn't take any more than PHP. There are
>50 ways to perform queries, and many of them are hard. Many are simple.
>
>
Agree. I use both ASP and PHP and it take me the same effort... building
the queries... the rest is simple details (open connection... open
database... in both... just diferent syntax).
>
>
>>ASP confuses functions and data structures--arrays and functions
>>
>>
>You'll have to explain that one.
>
>
>
>>ASP only recognizes strings as double-quote deliminited
>>
>>
>So what?
>
>
>>ASP does not have mult-line comments
>>
>>
>So what?
>
>
Would be nice for debuging purposes... but alas...
>>ASP doesn't understand external http or ftp resources
>>
>>
>You have to use COM for this. I do a lot of stuff with HTTP and FTP.
>
>
>
>>PHP has very straightforward type casting and conversion mechanisms
>>
>>
>This is easy in ASP as well.
>
>
>
>>PHP has output buffering and output filtering built in
>>
>>
>ASP does this (response.buffer/response.flush)
>
>
>
>>PHP is so much faster! (benchmarks that I've seen on linux/apache ->
>>win/iis)
>>
>>
>Apples > Oranges. So far, my evaluation (win/iis 5.0 for both) has been
>that ASP is faster.
>
What versions... benchmarks are worth about 0... and speed is a relative
concept... i aggree that php may be faster then ASP (my perception is
that it is...).
Is ASP fast enought for the job at hand? Is PHP fast enought for the job
at hand?
Otherwise, you can always program directly in C++ and build a ISAPI
filter (or an Apache Module) to manage all your needs... that would be
faster!
>>PHP can open ftp and http resources
>>
>>
>See above.
>
>
>
>>PHP has a very complete set of regular expressions that are tied nicely to
>>their string and array functions
>>
>>
>ASP has regular expressions and they work quite well.
>
>
>
>>PHP can send email without any additional downloads and cost
>>
>>
>ASP can too (Server.CreateObject("CDONTS.NewMail")). I'm not sure why
>companies sell products for this.
>
--- End Message ---
--- Begin Message ---
> I have 6 arrays with data and would like to have all possible
> combinations
> Eg.
>
> $a1 = array(1,2);
> $a2 = array(3,4);
> $a3 = array(5,6);
> $a4 = array(7,8);
> $a5 = array(9,10);
> $a6 = array(11,12);
>
> the result should then be a new array like this:
>
> [0] = 1,3,5,7,9,11
> [1] = 1,4,5,7,9,11
> [2] = 1,6,5,7,9,11
> etc....
>
> I know I end up with A LOT, but I need it ;-)
I did somethig similar once. First, put everything into one array to have it
more clearly adressed. It could be easier to help if you'd explain rules of
construction sets of digits. For example is this one correct "3,1,5,4,7,9"?
I it is, solution is quite simple. You will need second array (name it
'used[]') indicating which element is already used.
First, reset used[] array.
Then launch a function working like this:
void look4solution(0) /* this "0" is 'counter', initially set this way to 0
*/
{
if (counter==6) put_answer_into_array(answer);
/* answer is complete, so output it - but remember to put it into the new
row of output array - this function doesn't care about it */
/* now, put into answer[counter] first not previously used element... and
next... and so on... */
else for (i=1; i<=12; i++) if (!used[i])
{
/* we're just using i'th element so lock it... */
used[i]=true;
/* ...put into answer[]... */
answer[counter]=input[i];
/* ...use any unused on next position... */
look4solution(counter+1);
/* ...and free it! */
used[i]=fase;
}
}
I can't guaratee it is working code. I didn't test it but this idea is
good - Delphi program worked well but unfotunatelly I haven't it's source.
You should have output like this:
1,2,3,4,5,6
1,2,3,4,5,7
1,2,3,4,5,8
...
1,2,3,4,5,12
1,2,3,4,6,5
1,2,3,4,6,7
1,2,3,4,6,8
and so on
--- End Message ---