Obtaining certain characters

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

Post Reply
User avatar
farid
Forum Commoner
Posts: 54
Joined: Thu Nov 11, 2004 4:20 pm
Location: Mexico

Obtaining certain characters

Post by farid »

Hi y'all!!

Well Im trying to find a php function that can obtain certain number of characters from a date, that is, if I have the value :

2005-05-05 10:40:50.00

I must obtain only: 2005-05-05

Thanks!! :roll:
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Post by shiznatix »

if thats the situation do

Code: Select all

$other_var = '2005-05-05 10:40:50.00';
$some_var = explode(' ', $other_var);
//$some_var[0] will = 2005-05-05
User avatar
farid
Forum Commoner
Posts: 54
Joined: Thu Nov 11, 2004 4:20 pm
Location: Mexico

Post by farid »

jus´a thing, it appears this:

2005-05-05 10:40:50.00
Array

with

Code: Select all

echo $other_var = '2005-05-05 10:40:50.00', "<br>";
echo $some_var = explode(' ', $other_var);
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Post by shiznatix »

after echo $some_var = explode(' ', $other_var);

do

Code: Select all

print_r($some_var);
its a array so you cant just echo it out, if you echo it out you have to give it a certain key to echo out such as $some_var[0] 0 being the key and the brackets holding the key to the array. since your just echoing out $some_var you just see array because thats what $some_var is without a specified key
User avatar
farid
Forum Commoner
Posts: 54
Joined: Thu Nov 11, 2004 4:20 pm
Location: Mexico

Post by farid »

perfeeeeeect!! Cool man 8) Thanks ShizNatiX!!!
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Post by shiznatix »

haha no problem man but it is shiznatix, no uppercase characers :D . pronounced shiz nn A tix
Post Reply