FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » part two same issue - unwanted empty values in array
Show: Today's Messages :: Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
part two same issue - unwanted empty values in array [message #185738] Mon, 05 May 2014 15:04 Go to next message
Mr Oldies is currently offline  Mr Oldies
Messages: 241
Registered: October 2013
Karma: 0
Senior Member
http://mroldies.net/radio/24hours3.php

As you will see, at the bottom of the list I am left with the equal number
of unassigned array values that now contain nothing.
I don't even want that in the list.
How do I eliminate them altogether?
Re: part two same issue - unwanted empty values in array [message #185741 is a reply to message #185738] Mon, 05 May 2014 15:36 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 5/5/2014 11:04 AM, richard wrote:
> http://mroldies.net/radio/24hours3.php
>
> As you will see, at the bottom of the list I am left with the equal number
> of unassigned array values that now contain nothing.
> I don't even want that in the list.
> How do I eliminate them altogether?
>

Once again you didn't show your code, so it's impossible to tell.

You also have an invalid argument for foreach()...

With all of that, why aren't you using a database? You're going through
a whole lot of unnecessary work that the database can do for you.

--
==================
Remove the "x" from my email address
Jerry Stuckle
jstucklex(at)attglobal(dot)net
==================
Re: part two same issue - unwanted empty values in array [message #185742 is a reply to message #185741] Mon, 05 May 2014 15:40 Go to previous messageGo to next message
J.O. Aho is currently offline  J.O. Aho
Messages: 194
Registered: September 2010
Karma: 0
Senior Member
On 05/05/14 17:36, Jerry Stuckle wrote:
> On 5/5/2014 11:04 AM, richard wrote:
>> http://mroldies.net/radio/24hours3.php
>>
>> As you will see, at the bottom of the list I am left with the equal
>> number
>> of unassigned array values that now contain nothing.
>> I don't even want that in the list.
>> How do I eliminate them altogether?
>>
>
> Once again you didn't show your code, so it's impossible to tell.
>
> You also have an invalid argument for foreach()...
>
> With all of that, why aren't you using a database? You're going through
> a whole lot of unnecessary work that the database can do for you.
>

Maybe the guy who he hired once don't anymore answer the phone?

--

//Aho
Re: part two same issue - unwanted empty values in array [message #185744 is a reply to message #185741] Mon, 05 May 2014 16:38 Go to previous messageGo to next message
Mr Oldies is currently offline  Mr Oldies
Messages: 241
Registered: October 2013
Karma: 0
Senior Member
On Mon, 05 May 2014 11:36:25 -0400, Jerry Stuckle wrote:

> On 5/5/2014 11:04 AM, richard wrote:
>> http://mroldies.net/radio/24hours3.php
>>
>> As you will see, at the bottom of the list I am left with the equal number
>> of unassigned array values that now contain nothing.
>> I don't even want that in the list.
>> How do I eliminate them altogether?
>>
>
> Once again you didn't show your code, so it's impossible to tell.
>
> You also have an invalid argument for foreach()...
>
> With all of that, why aren't you using a database? You're going through
> a whole lot of unnecessary work that the database can do for you.

Just how does one use a database to play music with?
"Data" means information. It is not the file itself.

The array I am creating is a prelude to using the database.
Ergo, the crazy numbering scheme for the file names.
Each file name will correspond to the songID in the database.
That in turn, fetches the required information I want to display.
e.g. Track title, artist, year and rank.
Whereas I could just as easily use the basic information for file names, I
have found out that only ivites spiders and crawlers to take advantage and
identify who has that song.
I have checked my stats for links and found one guy who was directly
linking onto his site so his visitors could freely download.
I pointe out to him that was not only illegal, but as I had to pay a fee to
legally broadcast, I could sue him if it came to that.
As could BMI and ASCAP sue him.
He got the message and no longer links.
Since bots don't know what the numbers mean, it is useless information to
them.

As for the code, here is what I have so far.


$hi=0;

for ($i = 59; $i <= 69; $i++) {
$yr="19$i";

$dir='../audio/'.$yr.'/';
$files = scandir($dir);
$number=count($files);
sort($files);
$hi=$hi+$number;

foreach ($files as $file)
if ($file !=="." && $file !=="..")
$master[] = $file;
}
echo $hi;
echo "<br>";

sort($master);
for ($x=0;$x<=$hi;$x++){echo $x.")..".$master[$x]."<br>";}
Re: part two same issue - unwanted empty values in array [message #185745 is a reply to message #185744] Mon, 05 May 2014 16:51 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 5/5/2014 12:38 PM, richard wrote:
> On Mon, 05 May 2014 11:36:25 -0400, Jerry Stuckle wrote:
>
>> On 5/5/2014 11:04 AM, richard wrote:
>>> http://mroldies.net/radio/24hours3.php
>>>
>>> As you will see, at the bottom of the list I am left with the equal number
>>> of unassigned array values that now contain nothing.
>>> I don't even want that in the list.
>>> How do I eliminate them altogether?
>>>
>>
>> Once again you didn't show your code, so it's impossible to tell.
>>
>> You also have an invalid argument for foreach()...
>>
>> With all of that, why aren't you using a database? You're going through
>> a whole lot of unnecessary work that the database can do for you.
>
> Just how does one use a database to play music with?
> "Data" means information. It is not the file itself.
>

A file is nothing more than data. And a file system is nothing more
than a (non-SQL) database.

> The array I am creating is a prelude to using the database.
> Ergo, the crazy numbering scheme for the file names.
> Each file name will correspond to the songID in the database.
> That in turn, fetches the required information I want to display.
> e.g. Track title, artist, year and rank.
> Whereas I could just as easily use the basic information for file names, I
> have found out that only ivites spiders and crawlers to take advantage and
> identify who has that song.
> I have checked my stats for links and found one guy who was directly
> linking onto his site so his visitors could freely download.
> I pointe out to him that was not only illegal, but as I had to pay a fee to
> legally broadcast, I could sue him if it came to that.
> As could BMI and ASCAP sue him.
> He got the message and no longer links.

Putting music in the database means you need to serve the files with a
PHP script - but it also allows you to run some tests to see if someone
hotlinked to your files (i.e. "HTTP_REFER" is not a perfect test, but
works with most browsers).

> Since bots don't know what the numbers mean, it is useless information to
> them.
>
> As for the code, here is what I have so far.
>
>
> $hi=0;
>
> for ($i = 59; $i <= 69; $i++) {
> $yr="19$i";
>
> $dir='../audio/'.$yr.'/';
> $files = scandir($dir);
> $number=count($files);
> sort($files);
> $hi=$hi+$number;
>
> foreach ($files as $file)
> if ($file !=="." && $file !=="..")
> $master[] = $file;
> }
> echo $hi;
> echo "<br>";
>
> sort($master);
> for ($x=0;$x<=$hi;$x++){echo $x.")..".$master[$x]."<br>";}
>

Except $master does not have all of the entries that $files had, since
you didn't copy the "." and ".." files over.



--
==================
Remove the "x" from my email address
Jerry Stuckle
jstucklex(at)attglobal(dot)net
==================
Re: part two same issue - unwanted empty values in array [message #185746 is a reply to message #185744] Mon, 05 May 2014 17:03 Go to previous messageGo to next message
Denis McMahon is currently offline  Denis McMahon
Messages: 634
Registered: September 2010
Karma: 0
Senior Member
On Mon, 05 May 2014 12:38:27 -0400, richard wrote:

>>> As you will see, at the bottom of the list I am left with the equal
>>> number of unassigned array values that now contain nothing.

> As for the code, here is what I have so far.

You have made an error in your logic, such that $hi is greater than count
($master).

at the end:

sort($master);
for ( $x = 0; $x < count($master); $x++ )
echo "{$x})..{$master[$x]}<br>";

--
Denis McMahon, denismfmcmahon(at)gmail(dot)com
Re: part two same issue - unwanted empty values in array [message #185747 is a reply to message #185746] Mon, 05 May 2014 17:10 Go to previous messageGo to next message
Mr Oldies is currently offline  Mr Oldies
Messages: 241
Registered: October 2013
Karma: 0
Senior Member
On Mon, 5 May 2014 17:03:07 +0000 (UTC), Denis McMahon wrote:

> sort($master);
> for ( $x = 0; $x < count($master); $x++ )
> echo "{$x})..{$master[$x]}<br>";

thank you.
exactly what I needed.
Re: part two same issue - unwanted empty values in array [message #185748 is a reply to message #185746] Mon, 05 May 2014 17:23 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 5/5/2014 1:03 PM, Denis McMahon wrote:
> On Mon, 05 May 2014 12:38:27 -0400, richard wrote:
>
>>>> As you will see, at the bottom of the list I am left with the equal
>>>> number of unassigned array values that now contain nothing.
>
>> As for the code, here is what I have so far.
>
> You have made an error in your logic, such that $hi is greater than count
> ($master).
>
> at the end:
>
> sort($master);
> for ( $x = 0; $x < count($master); $x++ )
> echo "{$x})..{$master[$x]}<br>";
>

Or, better yet:

$top = count($master);
for ( $x = 0; $x < top; $x++)

That way count($master) doesn't have to be evaluated each time through
the loop. Minor savings, I know. But still good programming practice,
IMHO.

--
==================
Remove the "x" from my email address
Jerry Stuckle
jstucklex(at)attglobal(dot)net
==================
Re: part two same issue - unwanted empty values in array [message #185750 is a reply to message #185748] Mon, 05 May 2014 20:01 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 5/5/2014 1:23 PM, Jerry Stuckle wrote:
> On 5/5/2014 1:03 PM, Denis McMahon wrote:
>> On Mon, 05 May 2014 12:38:27 -0400, richard wrote:
>>
>>>> > As you will see, at the bottom of the list I am left with the equal
>>>> > number of unassigned array values that now contain nothing.
>>
>>> As for the code, here is what I have so far.
>>
>> You have made an error in your logic, such that $hi is greater than count
>> ($master).
>>
>> at the end:
>>
>> sort($master);
>> for ( $x = 0; $x < count($master); $x++ )
>> echo "{$x})..{$master[$x]}<br>";
>>
>
> Or, better yet:
>
> $top = count($master);
> for ( $x = 0; $x < top; $x++)
>
> That way count($master) doesn't have to be evaluated each time through
> the loop. Minor savings, I know. But still good programming practice,
> IMHO.
>

Correction:

$top = count($master);
for ( $x = 0; $x < $top; $x++)

I miss the '$' too, occasionally. Been doing too much C lately...

--
==================
Remove the "x" from my email address
Jerry Stuckle
jstucklex(at)attglobal(dot)net
==================
Re: part two same issue - unwanted empty values in array [message #185753 is a reply to message #185738] Tue, 06 May 2014 00:58 Go to previous messageGo to next message
Doug Miller is currently offline  Doug Miller
Messages: 171
Registered: August 2011
Karma: 0
Senior Member
richard <noreply(at)example(dot)com> wrote in news:10ij5epc7behi$.1xza6fsoj54ve$.dlg@
40tude.net:

> http://mroldies.net/radio/24hours3.php
>
> As you will see, at the bottom of the list I am left with the equal number
> of unassigned array values that now contain nothing.
> I don't even want that in the list.
> How do I eliminate them altogether?

How many times to I have to tell you this, Richard?

WE CAN'T SEE YOUR PHP CODE.
Re: part two same issue - unwanted empty values in array [message #185761 is a reply to message #185748] Tue, 06 May 2014 12:33 Go to previous messageGo to next message
Denis McMahon is currently offline  Denis McMahon
Messages: 634
Registered: September 2010
Karma: 0
Senior Member
On Mon, 05 May 2014 13:23:33 -0400, Jerry Stuckle wrote:

> That way count($master) doesn't have to be evaluated each time through
> the loop. Minor savings, I know. But still good programming practice,
> IMHO.

Doh, yeah, my bad.

--
Denis McMahon, denismfmcmahon(at)gmail(dot)com
Re: part two same issue - unwanted empty values in array [message #185763 is a reply to message #185744] Tue, 06 May 2014 17:49 Go to previous messageGo to next message
Luuk is currently offline  Luuk
Messages: 329
Registered: September 2010
Karma: 0
Senior Member
On 5-5-2014 18:38, richard wrote:
>
> sort($master);
> for ($x=0;$x<=$hi;$x++){echo $x.")..".$master[$x]."<br>";}
>


you could also stop this loop if $master[$x] is empty


for ($x=0;$x<=$master[$x]!="";$x++){echo $x.")..".$master[$x]."<br>";
Re: part two same issue - unwanted empty values in array [message #185764 is a reply to message #185747] Tue, 06 May 2014 17:53 Go to previous messageGo to next message
Denis McMahon is currently offline  Denis McMahon
Messages: 634
Registered: September 2010
Karma: 0
Senior Member
On Mon, 05 May 2014 13:10:16 -0400, richard wrote:

> On Mon, 5 May 2014 17:03:07 +0000 (UTC), Denis McMahon wrote:
>
>> sort($master);
>> for ( $x = 0; $x < count($master); $x++ )
>> echo "{$x})..{$master[$x]}<br>";

> thank you.
> exactly what I needed.

Not quite.

What you need is to understand how you made the error in the first place,
which I suspect is totally beyond your comprehension, and yet myself (and
I suspect several others here) spotted it almost straight away.

--
Denis McMahon, denismfmcmahon(at)gmail(dot)com
Re: part two same issue - unwanted empty values in array [message #185767 is a reply to message #185753] Wed, 07 May 2014 05:31 Go to previous message
Evan Platt is currently offline  Evan Platt
Messages: 124
Registered: November 2010
Karma: 0
Senior Member
On Tue, 6 May 2014 00:58:55 +0000 (UTC), Doug Miller
<doug_at_milmac_dot_com(at)example(dot)com> wrote:

> richard <noreply(at)example(dot)com> wrote in news:10ij5epc7behi$.1xza6fsoj54ve$.dlg@
> 40tude.net:
>
>> http://mroldies.net/radio/24hours3.php
>>
>> As you will see, at the bottom of the list I am left with the equal number
>> of unassigned array values that now contain nothing.
>> I don't even want that in the list.
>> How do I eliminate them altogether?
>
> How many times to I have to tell you this, Richard?
>
> WE CAN'T SEE YOUR PHP CODE.

It's pretty obvious he doesn't learn. I keep having to tell him the
same things over and over again. I don't know if it's Alzheimer's or
just pure stupidity, or both.

He likely burned his bridge with the 'programmer' he hired recently,
so now he's back here asking for help every other day, and people keep
helping him, and then he often abuses those providing him free help.
Where is his incentive to learn anything? All he has to do is come
here, and everyone solves his problems for him.

Perhaps if people stopped, he may actually learn something....
Although maybe I give him too much credit.
--
To reply via e-mail, remove The Obvious and .invalid from my e-mail address.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: how to join two arrays?
Next Topic: The goto statement in PHP
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Tue Nov 26 22:53:13 GMT 2024

Total time taken to generate the page: 0.02770 seconds