SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Wizard Darren884's Avatar
    Join Date
    Aug 2003
    Location
    Southern California, United States
    Posts
    1,616
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Variabel Setting Wont Work!

    I have the following code and I am try to get $tags to print:

    PHP Code:
    <?php

    $tags 
    '';
    $i 0;
    while (
    $i $total) {
       echo 
    '$object[' $i '] = &lt;' $objects[1][$i] . '&gt;';
       
    $tags .= $objects[1][$i];
       
    $end $total 1;
       if (
    $i != $end) {
          echo 
    ', ';
       }
       
    $i++;
    }

    echo 
    $tags;

    ?>
    But it just wont work... isnt that the right way to add onto a variable??
    Have a good day.

  2. #2
    SitePoint Wizard bronze trophy devbanana's Avatar
    Join Date
    Apr 2006
    Location
    Pennsylvania
    Posts
    1,736
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What does it print out? Is it entering the loop?

  3. #3
    SitePoint Wizard
    Join Date
    Mar 2001
    Posts
    3,537
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    $i 0;
    while (
    $i $total
    Error.

  4. #4
    SitePoint Addict
    Join Date
    Jan 2006
    Posts
    268
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    not as long as $total is set to above 0...

    is $total set somewhere above this? along with $objects?

  5. #5
    Obey the Purebreed trib4lmaniac's Avatar
    Join Date
    Dec 2004
    Location
    Cornwall, UK
    Posts
    594
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I may be taking liberties with your code, but is the following largely equivalent?
    PHP Code:
    for($i 0$i count($objects[1]); $i++) {
        echo 
    "\$objects[$i] = &lt;{$objects[1][$i]}&gt;";
        if(
    $i count($objects[1]) - 1) {
            echo 
    ", ";
        } else {
            echo 
    "<br/>";
        }
    }
    echo 
    implode(", "$objects[1]); 
    You just need to make sure that $objects[1] has an array of data contained in it.


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
  •