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

Home » Imported messages » comp.lang.php » upgrade of php & split deprecated = HELP
Show: Today's Messages :: Unread Messages :: Show Polls :: Message Navigator
| Subscribe to topic | Bookmark topic 
Switch to threaded view of this topic Create a new topic Submit Reply
upgrade of php & split deprecated = HELP [message #175024] Thu, 04 August 2011 00:38 Go to next message
horus is currently offline  horus
Messages: 2
Registered: August 2011
Karma: 0
Junior Member
add to buddy list
ignore all messages by this user
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):

<?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
Re: upgrade of php & split deprecated = HELP [message #175026 is a reply to message #175024] Thu, 04 August 2011 05:15 Go to previous messageGo to next message
tony is currently offline  tony
Messages: 19
Registered: December 2010
Karma: 0
Junior Member
add to buddy list
ignore all messages by this user
In article <4e3a2249$0$2195$742ec2ed(at)news(dot)sonic(dot)net>,
horus <horus(at)sonic(dot)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(at)softins(dot)co(dot)uk - http://www.softins.co.uk
Play: tony(at)mountifield(dot)org - http://tony.mountifield.org
Re: upgrade of php & split deprecated = HELP [message #175028 is a reply to message #175026] Thu, 04 August 2011 07:23 Go to previous message
horus is currently offline  horus
Messages: 2
Registered: August 2011
Karma: 0
Junior Member
add to buddy list
ignore all messages by this user
Many thanks Tony,

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(at)mountifield(dot)org> wrote in message
news:j1do07$gga$1(at)softins(dot)clara(dot)co(dot)uk...
> In article <4e3a2249$0$2195$742ec2ed(at)news(dot)sonic(dot)net>,
> horus <horus(at)sonic(dot)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(at)softins(dot)co(dot)uk - http://www.softins.co.uk
> Play: tony(at)mountifield(dot)org - http://tony.mountifield.org
Quick Reply
Formatting Tools:   
  Switch to threaded view of this topic Create a new topic
Previous Topic: mysql.dll won't load
Next Topic: What this means "(\w|-)+@\w"?
Goto Forum:
  

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

Current Time: Sun Oct 22 07:41:14 EDT 2017

Total time taken to generate the page: 0.00620 seconds