[PHP] array_unique() workaround?

2001-11-14 Thread Spunk S. Spunk III

I'm working on a script that needs array_unique() but my host is using 4.0.4
and it's broken in that build. Does anyone have a good workaround for this?
I can wait for my host to upgrade but if I release this code, it would be
better to have the workaround...

I just need a good way to check for dups in an array and remove them. I
can't get my brain around it...

TIA
Spunk


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] array_unique() workaround? SOLUTION!

2001-11-14 Thread Spunk S. Spunk III

Thanks everyone for the ideas,
Here's what I came up with...
I forgot to mention that I needed to preserve the original array's keys.
Here is a replacement I wrote that seems to work. Let me know if you see
errors in it or have improvements.

function my_array_unique($somearray)
{
asort($somearray);
reset($somearray);
$currentarrayvar = current($somearray);
foreach ($somearray as $key=$var)
{
if (next($somearray) != $currentarrayvar)
{
$uniquearray[$key] = $currentarrayvar;
$currentarrayvar = current($somearray);
} 
} 
reset($uniquearray);
return $uniquearray;
}


 
 I'm working on a script that needs array_unique() but my host is using 4.0.4
 and it's broken in that build. Does anyone have a good workaround for this?
 I can wait for my host to upgrade but if I release this code, it would be
 better to have the workaround...
 
 I just need a good way to check for dups in an array and remove them. I
 can't get my brain around it...
 
 TIA
 Spunk
 
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]
 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] is_null misses spaces... another solution?

2001-11-13 Thread Spunk S. Spunk III

I need to check variables for blank values but it appears that is_null and
== return true if there is a space.

Any other suggestions?

Thanks


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] is_null misses spaces... SOLUTION!

2001-11-13 Thread Spunk S. Spunk III

Ahh...
and the winner is empty().

Thanks Christian for this elusive answer and everyone else for their input.

Spunk


 
 I need to check variables for blank values but it appears that is_null and
 == return true if there is a space.
 
 Any other suggestions?
 
 Thanks
 
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]
 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] variable gets lost in function problem again...

2001-10-26 Thread Spunk S. Spunk III

Sorry all but I really need to figure this out. Here's a recap of my
problem:

I have an two dimensional array that is returned from code from an included
file. I'm assigning parts of the array to variables ( $variable =
$array[key][value]; ). This works fine and can be printed until I send
it through a function eg. ( ereg_replace( , _, $variable); ). After
this, $variable is blank.

I don't think it's my code because substituting a text string for the array
data (eg. $variable = this is some text;) works just fine.

It has something to do with the assigning array data to a variable or
perhaps that the data comes from an included file... This could be a bug in
PHP? 

Does this sound familiar to anybody? I can't figure it out! Any help would
be much appreciated.

Thanks,
Spunk


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] passing a multi dimensional associative array...

2001-10-25 Thread Spunk S. Spunk III

Pardon me if I've been smoking too much crack but I can't seem to figure
this one out...

How do I pass an argument to a function that contains a value from multi
dimensional associative array?

or... How do I pass an variable as an argument that contains value taken
from an array?

or... Why doesn't the following work? The following (barring any typos)
works for me if the variable $newstring is passed with a value of Some
Random Text (it is returned with spaces replace by underscores) but does
not work when passing the $newstring = $somearray[thing][data] line.
I'm missing something here...

TIA,
Spunk


?php

function RemoveWeirdChars($stringtoreplace)
{
// Removes spaces that could cause problems.
$replacedstring = (ereg_replace( , _, $stringtoreplace));
return $replacedstring;
}

//$newstring = Some Random Text; //This works...
//value comes from an multi-assoc-array
$newstring = $somearray[thing][data]; //doesn't work

//$finishedstring = (ereg_replace( , _, $newstring));
$finishedstring = (RemoveWeirdChars($newstring));
echo $finishedstring;
?



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] argument variable gets lost in function

2001-10-25 Thread Spunk S. Spunk III

I'm assigning a variable a value from an associative array.
$variable = $array[key][value];

Then passing the $variable to a function.
SomeFunction($variable)

The variable exists (can be printed) until a built-in function (within the
original function) is called.
echo $variable; //prints out fine
$variable2 = ereg_replace( , _, $variable);
echo $variable; //prints out NOTHING...

Why is this and how can I get around it?

Thanks,
Spunk



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Re: argument variable gets lost in function

2001-10-25 Thread Spunk S. Spunk III

 
 hmm...weird! is that the code?
 if you show us your real code...maybe you're missing a small detail...

Sorry about the variable names... I can print the variable inside the
function until it goes through ereg_replace. Then it's gone. The code works
fine if I replace the line '$song = $id3info[TIT2][data];' with '$song =
some text string;' Since it's getting the variables value from an included
file's functions that return and assoc. array... it's a bit confusing. I
everything is fine up till the built-in function (inside my function) is
called. Weird is right...

?php

include(getid3.php);
 
function RemoveSpaces($shittoreplace)
{
// Removes spaces and other characters that could cause problems.
$shittoreplace = ereg_replace( , _, $shittoreplace);
return $shittoreplace;
}

$id3info = (getID3(music.mp3));
$song = $id3info[TIT2][data];
$newsong = RemoveSpaces($song);

echo $newsong;

?


 I'm assigning a variable a value from an associative array.
 $variable = $array[key][value];
 
 Then passing the $variable to a function.
 SomeFunction($variable)
 
 The variable exists (can be printed) until a built-in function (within the
 original function) is called.
 echo $variable; //prints out fine
 $variable2 = ereg_replace( , _, $variable);
 echo $variable; //prints out NOTHING...
 
 Why is this and how can I get around it?


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Change the filename sent via html header

2001-04-03 Thread Spunk S. Spunk III

I've got a script that returns a smil file in a header but I'd like to
change the name of the file. The file is sent as blah.php (even though it is
a smil file) but I'd like to be able to name it something like blah.sml. Is
there a way to do this?

Spunk


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Change the filename sent via html header

2001-04-03 Thread Spunk S. Spunk III

Okay,
So here's what it looks like now:

header("Content-type: application/x-quicktimeplayer");
header("Content-Disposition: attachment; filename=blah.qtl" );
print(GenerateSMILAlbum($baseURL, $directory, $mp3Array, $albumCover));

This gets me two download dialogs on windows machines if I select "Open in
Place" and does not rename the file to blah.qtl when downloaded on a Mac...

Any suggestions? Thanks for the comments...

Spunk


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Getting a header without ANY mime type

2001-03-22 Thread Spunk S. Spunk III

This would be part of a test tool I'd like to create in order to test
conditions of an application. I want to send a request and ensure that the
response has no set type or known length if possible (eg return some media
that is undefined and see how the app handles the response).

Anyone?

Spunk

 
 On Thursday 22 March 2001 02:32, you wrote:
 I've got a situation where I'm interested in returning a header without
 ANY mime type specified. It looks like the default Mime type is set by
 the server (plain text)? Or at least when I don't specify the type
 
 It's set by PHP (text/html)
 
 that's what my server is returning. I'd also like to ensure that there
 is no content length returned. Is this possible?
 
 So you want to give the browser something and make really sure that it
 has no chance of interpreting it correctly? Perhaps I miss something, but
 unless your visitors are masochists with too much time on their hands
 that's a sure way to lose them really quickly.


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Getting a header without ANY mime type

2001-03-21 Thread Spunk S. Spunk III

I've got a situation where I'm interested in returning a header without ANY
mime type specified. It looks like the default Mime type is set by the
server (plain text)? Or at least when I don't specify the type that's what
my server is returning. I'd also like to ensure that there is no content
length returned. Is this possible?

Spunk


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]