SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member
    Join Date
    Nov 2006
    Location
    Melbourne,Australia
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Thumbs up php explode issue

    Hi,

    I have array(info) which contain value separated by @.
    Code PHP:
     
    info Array ( [0] => 1@1@2011-09-06 [1] => 61@11@2001-01-01 [2] => 781@13@2001-01-01 )

    and my php function contain following

    Code PHP:
     
    for($j=0;$j<count(info);$j++)
    {
        $value=$info[$j];
        $rowval=explode('@',$value);
        echo $id=$rowval[0];
    }
    it should print 1,61,781. it is printing noting. It does not make any sense!

    Please help.

  2. #2
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    16,448
    Mentioned
    160 Post(s)
    Tagged
    1 Thread(s)
    What does
    PHP Code:
    # DEVELOPMENT + DEBUGGING
    error_reporting(E_ALL);
    ini_set('display_errors'true);
    .....
    echo 
    count(info); 
    give you?

  3. #3
    SitePoint Member
    Join Date
    Nov 2006
    Location
    Melbourne,Australia
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,
    fixed . Thanks Mittineague .for remind me to turn on error reporting.
    It was wrong variable &loop issue.

  4. #4
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    16,448
    Mentioned
    160 Post(s)
    Tagged
    1 Thread(s)
    Hmmm. try
    PHP Code:
    for($j=0;$j<count(info);$j++)
    {
    var_dump($info);//for debugging only
        
    $value=$info[$j];
    var_dump($value);//for debugging only
        
    $rowval=explode('@',$value);
        echo 
    $id=$rowval[0];


  5. #5
    Non-Member bronze trophy
    Join Date
    Nov 2009
    Location
    Keene, NH
    Posts
    3,760
    Mentioned
    23 Post(s)
    Tagged
    0 Thread(s)
    Yeah,I was going to point out that you had no $ on count(info) ... glad you got it sorted.

    Some advice though -- it's an array, use foreach.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •