FUDforum - خوراک RDF
http://fudforum.org/forum/index.php
upgrade of php & split deprecated = HELP
http://fudforum.org/forum/index.phpindex.php?t=rview&goto=175024&th=122239#msg_175024
Undefined offset: 2 in /var/www/html/testing/blah/blah/aitoff.php on line
16, referer: httpd://blah.blah.blah/
Undefined offset: 1 in /var/www/html/testing/blah/blah/aitoff.php on line
16, referer: httpd://blah.blah.blah/
here's the code(i've tried the preg_split, & explode):
<?php
class AstronomicalObject{
var $ra;
var $dec;
var $minBrightness;
var $maxBrightness;
dmc]]>horus2011-08-04T04:38:31-00:00Re: upgrade of php & split deprecated = HELP
http://fudforum.org/forum/index.phpindex.php?t=rview&goto=175026&th=122239#msg_175026
742ec2ed@news.sonic.net>,
horus <horus@sonic.net> wrote:
> explode & preg_split produces:
> Undefined offset: 2 in /var/www/html/testing/blah/blah/aitoff.php on line
> 16, referer: httpd://blah.blah.blah/
> Undefined offset: 1 in /var/www/html/testing/blah/blah/aitoff.php on line
> 16, referer: httpd://blah.blah.blah/
>
> here's the code(i've tried the preg_split, & explode):
To use preg_split, you need to add pattern delimiters:
$foo = preg_split('/[\ :]/', $bar);
Without them, the [ and ] are acting as pattern delimiters, not as the
container for a character class.
--
Tony Mountifield
Work: tony@softins.co.uk - http://www.softins.co.uk
Play: tony@mountifield.org - http://tony.mountifield.org]]>tony2011-08-04T09:15:51-00:00Re: upgrade of php & split deprecated = HELP
http://fudforum.org/forum/index.phpindex.php?t=rview&goto=175028&th=122239#msg_175028
It's been like 13 years since I've read the MasteringRegularExpressions
book, suppose it's time to brush up.
DOH!
-dmc
"Tony Mountifield" <tony@mountifield.org> wrote in message
news:j1do07$gga$1@softins.clara.co.uk...
> In article <4e3a2249$0$2195$742ec2ed@news.sonic.net>,
> horus <horus@sonic.net> wrote:
>> explode & preg_split produces:
>> Undefined offset: 2 in /var/www/html/testing/blah/blah/aitoff.php on line
>> 16, referer: httpd://blah.blah.blah/
>> Undefined offset: 1 in /var/www/html/testing/blah/blah/aitoff.php on line
>> 16, referer: httpd://blah.blah.blah/
>>
>> here's the code(i've tried the preg_split, & explode):
>
> To use preg_split, you need to add pattern delimiters:
>
> $foo = preg_split('/[\ :]/', $bar);
>
> Without them, the [ and ] are acting as pattern delimiters, not as the
> container for a character class.
>
> Cheers
> Tony
>
>> <?php
>> class AstronomicalObject{
>> var $ra;
>> var $dec;
>> var $minBrightness;
>> var $maxBrightness;
>>
>> function AstronomicalObject($raIn = "00:00:00.000",
>> $decIn = "00:00:00.000", $maxBrightness = "0",
>> $minBrightness = "30"){
>> // Initiate varibles
>> $this->ra = array("hours" => 0, "minutes" => 0, "seconds"
>> =>
>> 0);
>> $this->dec = array("degrees" => 0, "minutes" => 0,
>> "seconds"
>> => 0);
>>
>> // convert strings to numbers
>> list($this->ra["hours"], $this->ra["minutes"],
>> $this->ra["seconds"]) =
>> split('[\ :]', $raIn);
>>
>> $temp = split('[\ :]', $decIn);
>>
>> if(count($temp) == 2){
>> list($this->dec["degrees"],
>> $this->dec["minutes"]) =
>> $temp;
>> }elseif(count($temp) == 3){
>> list($this->dec["degrees"],
>> $this->dec["minutes"],
>> $this->dec["seconds"]) = $temp;
>> }
>>
>> $this->minBrightness = $minBrightness;
>> $this->maxBrightness = $maxBrightness;
>> }
>>
>>
>> thanks ahead of time
>>
>> dmc
>>
>>
>>
>
>
> --
> Tony Mountifield
> Work: tony@softins.co.uk - http://www.softins.co.uk
> Play: tony@mountifield.org - http://tony.mountifield.org]]>horus2011-08-04T11:23:37-00:00