Re: [PHP] help me split chars w/o spaces by 2... like: 2004

2004-12-09 Thread ApexEleven
I did something like this a while back, I believe I used chunk_split

[code]
?

$year_split = date(Y);
$chars = chunk_split($year_split,2);
print_r($chars);

?
[/code]

it'll output something along the lines of:
20
04

Hope this helps,

-- 

Jasper Howard - Database Administration
ApexEleven.com
530 559 0107
---

On Thu, 9 Dec 2004 10:21:49 +0800, Louie Miranda [EMAIL PROTECTED] wrote:
 ?php
 $hello2 = chop($year_split);
 echo $hello2;
 ?
 
 outputs: 2004
 
 Whats the correct syntax for it? The manual said..
 
 This function is an alias of rtrim().
 
 and:
 
 rtrim
 (PHP 3, PHP 4 )
 
 rtrim --  Strip whitespace from the end of a string
 
 
 
 
 On Wed, 08 Dec 2004 18:11:19 -0800, Tyler Replogle [EMAIL PROTECTED] wrote:
  have you tride using chop() ?
  # begin code
  $year_split = date(Y);
  $chars = chop($year_split);
  $chars[0] // = 2
  $chars[1] // = 0
  $chars[2] // = 0
  $chars[3]  //= 4
  # end code
  I hope that will help
 
  From: Louie Miranda [EMAIL PROTECTED]
  Reply-To: Louie Miranda [EMAIL PROTECTED]
  To: [EMAIL PROTECTED]
  Subject: [PHP] help me split chars w/o spaces by 2... like: 2004
  Date: Thu, 9 Dec 2004 09:55:57 +0800
  MIME-Version: 1.0
  Received: from pb1.pair.com ([216.92.131.4]) by mc6-f24.hotmail.com with
  Microsoft SMTPSVC(5.0.2195.6713); Wed, 8 Dec 2004 17:56:52 -0800
  Received: (qmail 21242 invoked by uid 1010); 9 Dec 2004 01:56:02 -
  Received: (qmail 21150 invoked by uid 1010); 9 Dec 2004 01:56:01 -
  X-Message-Info: 6sSXyD95QpUKIecQn+Z/xIP21pcg8LTu
  Mailing-List: contact [EMAIL PROTECTED]; run by ezmlm
  Precedence: bulk
  list-help: mailto:[EMAIL PROTECTED]
  list-unsubscribe: mailto:[EMAIL PROTECTED]
  list-post: mailto:[EMAIL PROTECTED]
  Delivered-To: mailing list [EMAIL PROTECTED]
  Delivered-To: [EMAIL PROTECTED]
  Delivered-To: [EMAIL PROTECTED]
  DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws;s=beta;
  d=gmail.com;
  h=received:message-id:date:from:reply-to:to:subject:mime-version:content-type:content-transfer-encoding;
  
  b=gp2OcpYqK7wZkSMBhO5OvxdTzhTOQdM1+n9ZtLJ4lmsKWFpVRb9Y2kyjNIrRIX/rvXeFfwCVGh7LT6kub0DMmCGdeRiLKeCjJkxK4fWxSrP2D+FexciD2lT8ASKD7TNYC3YGIZLZbk5UEJIq9Yx2TkbIdgNd/Op3+iEviy1scI4=
  Return-Path: [EMAIL PROTECTED]
  X-OriginalArrivalTime: 09 Dec 2004 01:56:53.0406 (UTC)
  FILETIME=[5AF313E0:01C4DD92]
 
 
  
  Help me split chars w/o spaces by 2... like: 2004
  How can i make it?
  
  first: 20
  second: 04
  
  Im working on this..
  
  # begin code
  $year_split = date(Y);
  $chars = preg_split('//', $year_split, -1, PREG_SPLIT_NO_EMPTY);
  # end code
  
  But it splits the whole 2004 string..
  
  Array
  (
   [0] = 2
   [1] = 0
   [2] = 0
   [3] = 4
  )
  
  
  --
  Louie Miranda
  http://www.axishift.com
  
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
  
 
 
 
 --
 Louie Miranda
 http://www.axishift.com
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 


-- 

Jasper Howard - Database Administration
ApexEleven.com
530 559 0107
---

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] help me split chars w/o spaces by 2... like: 2004

2004-12-08 Thread Tyler Replogle
have you tride using chop() ?
# begin code
$year_split = date(Y);
$chars = chop($year_split);
$chars[0] // = 2
$chars[1] // = 0
$chars[2] // = 0
$chars[3]  //= 4
# end code
I hope that will help
From: Louie Miranda [EMAIL PROTECTED]
Reply-To: Louie Miranda [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Subject: [PHP] help me split chars w/o spaces by 2... like: 2004
Date: Thu, 9 Dec 2004 09:55:57 +0800
MIME-Version: 1.0
Received: from pb1.pair.com ([216.92.131.4]) by mc6-f24.hotmail.com with 
Microsoft SMTPSVC(5.0.2195.6713); Wed, 8 Dec 2004 17:56:52 -0800
Received: (qmail 21242 invoked by uid 1010); 9 Dec 2004 01:56:02 -
Received: (qmail 21150 invoked by uid 1010); 9 Dec 2004 01:56:01 -
X-Message-Info: 6sSXyD95QpUKIecQn+Z/xIP21pcg8LTu
Mailing-List: contact [EMAIL PROTECTED]; run by ezmlm
Precedence: bulk
list-help: mailto:[EMAIL PROTECTED]
list-unsubscribe: mailto:[EMAIL PROTECTED]
list-post: mailto:[EMAIL PROTECTED]
Delivered-To: mailing list [EMAIL PROTECTED]
Delivered-To: [EMAIL PROTECTED]
Delivered-To: [EMAIL PROTECTED]
DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws;s=beta; 
d=gmail.com;
h=received:message-id:date:from:reply-to:to:subject:mime-version:content-type:content-transfer-encoding; 
   
b=gp2OcpYqK7wZkSMBhO5OvxdTzhTOQdM1+n9ZtLJ4lmsKWFpVRb9Y2kyjNIrRIX/rvXeFfwCVGh7LT6kub0DMmCGdeRiLKeCjJkxK4fWxSrP2D+FexciD2lT8ASKD7TNYC3YGIZLZbk5UEJIq9Yx2TkbIdgNd/Op3+iEviy1scI4=
Return-Path: [EMAIL PROTECTED]
X-OriginalArrivalTime: 09 Dec 2004 01:56:53.0406 (UTC) 
FILETIME=[5AF313E0:01C4DD92]

Help me split chars w/o spaces by 2... like: 2004
How can i make it?
first: 20
second: 04
Im working on this..
# begin code
$year_split = date(Y);
$chars = preg_split('//', $year_split, -1, PREG_SPLIT_NO_EMPTY);
# end code
But it splits the whole 2004 string..
Array
(
[0] = 2
[1] = 0
[2] = 0
[3] = 4
)
--
Louie Miranda
http://www.axishift.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] help me split chars w/o spaces by 2... like: 2004

2004-12-08 Thread Robby Russell
On Thu, 2004-12-09 at 09:55 +0800, Louie Miranda wrote:
 Help me split chars w/o spaces by 2... like: 2004
 How can i make it?
 
 first: 20
 second: 04
 
 Im working on this..
 
 # begin code
 $year_split = date(Y);
 $chars = preg_split('//', $year_split, -1, PREG_SPLIT_NO_EMPTY);
 # end code
 
 But it splits the whole 2004 string..
 
 Array
 (
 [0] = 2
 [1] = 0
 [2] = 0
 [3] = 4
 )
 
 

First of all, what sort of code are you building that needs to split the
year by 2 sets of 2 digits?

Second, you can do this like so:

$foo = date(Y);

$bar = array();

$bar[] = substr($foo,0,2);
$bar[] = substr($foo,2,2);

print_r($bar);


 Array
 (
 [0] = 20
 [1] = 04
 )


-Robby

-- 
/***
* Robby Russell | Owner.Developer.Geek
* PLANET ARGON  | www.planetargon.com
* Portland, OR  | [EMAIL PROTECTED]
* 503.351.4730  | blog.planetargon.com
* PHP/PostgreSQL Hosting  Development
*--- Now supporting PHP5 ---
/


signature.asc
Description: This is a digitally signed message part


Re: [PHP] help me split chars w/o spaces by 2... like: 2004

2004-12-08 Thread Louie Miranda
?php
$hello2 = chop($year_split);
echo $hello2;
?

outputs: 2004

Whats the correct syntax for it? The manual said.. 

This function is an alias of rtrim(). 

and: 

rtrim
(PHP 3, PHP 4 )

rtrim --  Strip whitespace from the end of a string 



On Wed, 08 Dec 2004 18:11:19 -0800, Tyler Replogle [EMAIL PROTECTED] wrote:
 have you tride using chop() ?
 # begin code
 $year_split = date(Y);
 $chars = chop($year_split);
 $chars[0] // = 2
 $chars[1] // = 0
 $chars[2] // = 0
 $chars[3]  //= 4
 # end code
 I hope that will help
 
 From: Louie Miranda [EMAIL PROTECTED]
 Reply-To: Louie Miranda [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Subject: [PHP] help me split chars w/o spaces by 2... like: 2004
 Date: Thu, 9 Dec 2004 09:55:57 +0800
 MIME-Version: 1.0
 Received: from pb1.pair.com ([216.92.131.4]) by mc6-f24.hotmail.com with
 Microsoft SMTPSVC(5.0.2195.6713); Wed, 8 Dec 2004 17:56:52 -0800
 Received: (qmail 21242 invoked by uid 1010); 9 Dec 2004 01:56:02 -
 Received: (qmail 21150 invoked by uid 1010); 9 Dec 2004 01:56:01 -
 X-Message-Info: 6sSXyD95QpUKIecQn+Z/xIP21pcg8LTu
 Mailing-List: contact [EMAIL PROTECTED]; run by ezmlm
 Precedence: bulk
 list-help: mailto:[EMAIL PROTECTED]
 list-unsubscribe: mailto:[EMAIL PROTECTED]
 list-post: mailto:[EMAIL PROTECTED]
 Delivered-To: mailing list [EMAIL PROTECTED]
 Delivered-To: [EMAIL PROTECTED]
 Delivered-To: [EMAIL PROTECTED]
 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws;s=beta;
 d=gmail.com;
 h=received:message-id:date:from:reply-to:to:subject:mime-version:content-type:content-transfer-encoding;
 
 b=gp2OcpYqK7wZkSMBhO5OvxdTzhTOQdM1+n9ZtLJ4lmsKWFpVRb9Y2kyjNIrRIX/rvXeFfwCVGh7LT6kub0DMmCGdeRiLKeCjJkxK4fWxSrP2D+FexciD2lT8ASKD7TNYC3YGIZLZbk5UEJIq9Yx2TkbIdgNd/Op3+iEviy1scI4=
 Return-Path: [EMAIL PROTECTED]
 X-OriginalArrivalTime: 09 Dec 2004 01:56:53.0406 (UTC)
 FILETIME=[5AF313E0:01C4DD92]
 
 
 
 Help me split chars w/o spaces by 2... like: 2004
 How can i make it?
 
 first: 20
 second: 04
 
 Im working on this..
 
 # begin code
 $year_split = date(Y);
 $chars = preg_split('//', $year_split, -1, PREG_SPLIT_NO_EMPTY);
 # end code
 
 But it splits the whole 2004 string..
 
 Array
 (
  [0] = 2
  [1] = 0
  [2] = 0
  [3] = 4
 )
 
 
 --
 Louie Miranda
 http://www.axishift.com
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 


-- 
Louie Miranda
http://www.axishift.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php