[thelist] PHP - RegExp & Array problems

Lachlan Cannon luminosity at members.evolt.org
Sat Jun 22 03:44:01 CDT 2002


Ok, first of all, as is visible on my site (link at bottom), for some reason
the word "Array" is being injected into a variable by PHP. I have no idea
why. The code where the variable is used goes like this:

$styles = '';
for ($i=0; $i<count($stylelist); $i++) {
	if ($stylelist[$i]['title'] != $prefstyle && $stylelist[$i]['media'] ==
'screen') {
		$styles .= "t".'<link rel="alternate stylesheet"
href="/luminosity/style/'.$stylelist[$i]['name'].'.css"
media="'.$stylelist[$i]['media'].'" title="'.$stylelist[$i]['title'].'"
type="text/css" />'."n";
	}
	else {
		$styles .= "t".'<link rel="stylesheet"
href="/luminosity/style/'.$stylelist[$i]['name'].'.css"
media="'.$stylelist[$i]['media'].'" title="'.$stylelist[$i]['title'].'"
type="text/css" />'."n";
	}
}

That's it, and somehow the word "Array" is appended to the start of the
string. Any idea why?

Secondly, I'm having trouble with my regexp for selecting URLs. It works
fine as it is, however if there is a period at the end, for the end of a
sentence that is also selected as part of the URL. How do I change it so
that it will select any url it currently does except if the last character
is a period (and in that case select up to the period).

The regexp I use currently is:

$comment =
eregi_replace('(http://(([A-Za-z0-9.-_])*)([A-Za-z0-9./-_])*)','<a
href="\1">\1</a>',$comment);

Also, while I'm at it, what would be a good regexp for selecting a pair of
double quotes inside a paragraph (seperated by line breaks), and
transforming them into a <q> and </q> if it was indeed a pair inside the one
para?

<tip type="Adjusting MySQL date values" author="Lachlan">
If you need to adjust the date value automatically inserted into a date
field on your server to bring the date into your timezone use the following
code:

NOW() + INTERVAL x HOUR

Where x is the number of hours.
</tip>

Thanks,
Lach
_____________________________________
http://members.evolt.org/luminosity/
MSN: luminosity @ members.evolt.org
_____________________________________





More information about the thelist mailing list