PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
emanresusdrawkcab
Forum Newbie
Posts: 4 Joined: Wed Dec 15, 2004 8:26 pm
Location: Melbourne, Australia
Post
by emanresusdrawkcab » Wed Dec 15, 2004 8:31 pm
what would be the pattern thingo for a date like
?
i've got a load of them in an array, and I want to get rid of them.
i tried
Code: Select all
$pattern = "(\d+)-(\d+)-(\d+)T(\d+):(\d+):(\d+)Z";
preg_replace($modPat,"", $arrayWithStuff); but it buggered up....
thanks in advance,
matt.
rehfeld
Forum Regular
Posts: 741 Joined: Mon Oct 18, 2004 8:14 pm
Post
by rehfeld » Wed Dec 15, 2004 8:36 pm
the pattern looks ok, i think you just forgot the delimiters
Code: Select all
<?php
$pattern = "/(\d+)-(\d+)-(\d+)T(\d+):(\d+):(\d+)Z/";
preg_replace($pattern,"", $arrayWithStuff);
?>
Last edited by
rehfeld on Wed Dec 15, 2004 8:42 pm, edited 1 time in total.
emanresusdrawkcab
Forum Newbie
Posts: 4 Joined: Wed Dec 15, 2004 8:26 pm
Location: Melbourne, Australia
Post
by emanresusdrawkcab » Wed Dec 15, 2004 8:39 pm
nope, still not working :'(
oh yeah, and I made sure my variables had the same name
rehfeld
Forum Regular
Posts: 741 Joined: Mon Oct 18, 2004 8:14 pm
Post
by rehfeld » Wed Dec 15, 2004 8:43 pm
is there an error?
instead of
([\d]+)
try
([0-9]+)
emanresusdrawkcab
Forum Newbie
Posts: 4 Joined: Wed Dec 15, 2004 8:26 pm
Location: Melbourne, Australia
Post
by emanresusdrawkcab » Wed Dec 15, 2004 8:47 pm
nope, it either returns what i originally had, or it's returning "Array" so i probably need to have a "print_r" somewhere
Code: Select all
$pattern = "/(\d+)-(\d+)-(\d+)T(\d+):(\d+):(\d+)Z/";
$myArray = (ereg_replace($pattern, "", $myArray));
print_r($myArray);
oh yeah, am i supposed to be using Preg or Ereg ?
emanresusdrawkcab
Forum Newbie
Posts: 4 Joined: Wed Dec 15, 2004 8:26 pm
Location: Melbourne, Australia
Post
by emanresusdrawkcab » Wed Dec 15, 2004 8:52 pm
i've done it! thanks for your help
Code: Select all
$pattern = "/(ї0-9]+)-(ї0-9]+)-(ї0-9]+)T(ї0-9]+):(ї0-9]+):(ї0-9]+)Z/";
$myArray = preg_replace($pattern, "", $myArray);
print_r($myArray);