[Phpsig] First PHP script

bill phpsig@kalamazoolinux.org
Fri, 12 Apr 2002 10:18:46 -0400


Hi Paul,

Paul VandenBosch wrote:

> Thanks, Bill;
>
> On Wednesday 10 April 2002 11:50 pm, you wrote:
>
> > If you echo the data and remove the entry entirely from the array when it
> > is "blipped" you wouldn't have to worry about duplicates.
>
> Would you use unset() to remove the data?
> Or just use $booklist[x][y] = 0?

unset

> Is there a way to reindex the array?
> How would you avoid printing the null or zero value if the array were not
> indexed?

You could reindex the array but it's simpler to learn to walk the array:

while (list($key,$value)=each($myarray) {
    // do stuff
    // $key will be the index of each set element
    // $value will the be the value of that element, natch

} // end while


> > Lastly, put a line break in your code to make it easier when you "View
> > Source" in the browser:
> >
> >         echo '"></a>\n';
>
> I tried this and Konqueror prints nice little \n's between the images.

Yes, you're using a lot of lines to do a little code.  It's simpler to use one
echo and use double quotes throughout.

echo "<a href=\"$somevalue\">$sometext</a>\n";

You can even span lines if it gets long:

echo "<a href=\"$somevalue\">$sometext
and some more text</a>\n";

kind regards,

bill hollett