Buying Looping Problem - $5 for Resolution

Discussion in 'Programming' started by Infranight, Dec 18, 2010.

  1. #1
    Job finished.
     
    Last edited: Dec 18, 2010
    Infranight, Dec 18, 2010 IP
  2. dpacmittal

    dpacmittal Well-Known Member

    Messages:
    155
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    103
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #2
    Here's the fix:
    
    $words = "put-it-goot-it";
    $words = explode('-', $words);
    foreach($words as &$hword){
    $hword = $hword.'ha';
    
    }
    $word = implode('-', $words);
    echo $word;
    
    Code (markup):

    Fixed your own code as well:
    
            $words = explode('-', $word); 
            $hnewPhrase='';
    	foreach ($words as $hword) {
    		$hnewPhrase[] = $hword.'ha';
    	}
    	$hstring = implode('-', $hnewPhrase);
    	$newPhrase[] = $hstring.$punc;
    
    Code (markup):
     
    dpacmittal, Dec 18, 2010 IP
  3. ankit_frenz

    ankit_frenz Active Member

    Messages:
    1,111
    Likes Received:
    41
    Best Answers:
    0
    Trophy Points:
    63
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #3
    output: putha-it gootha-itha
     
    ankit_frenz, Dec 18, 2010 IP
  4. Infranight

    Infranight Member

    Messages:
    319
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    28
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #4
    Sorry, it doesn't seem as though this is a problem a little snippet being provided can fix.
    PM me for a full version of the code.
     
    Infranight, Dec 18, 2010 IP
  5. dpacmittal

    dpacmittal Well-Known Member

    Messages:
    155
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    103
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #5
    @ankit_frenz:
    You just copy pasted his code which doesn't work if you put it inside another for loop. You have to initialize $hnewphrase to empty first.
     
    dpacmittal, Dec 18, 2010 IP
  6. Infranight

    Infranight Member

    Messages:
    319
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    28
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #6
    Oh, I see now, I forgot to empty. PM or reply with your PayPal (dpacmittal) and I'll send over the $5.
     
    Infranight, Dec 18, 2010 IP
  7. Vendor-Lock.com

    Vendor-Lock.com Peon

    Messages:
    21
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #7
    Hello Infranight,

    Have you tried using " if else and while " statements ?

    I'm sure there are people here more advanced then I,
    but I don't see any suggestions here for use of " if " " else " and " while " statements.

    I use them to accomplish similar jobs. I just discovered this forum, so I don't have
    enough posts to give you a link here for some good help with that.

    PM me if you want some help with that and I'll give you a link to some really good tutorials.

    cheers
    Jeff
     
    Vendor-Lock.com, Dec 18, 2010 IP
  8. ankit_frenz

    ankit_frenz Active Member

    Messages:
    1,111
    Likes Received:
    41
    Best Answers:
    0
    Trophy Points:
    63
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #8
    He never mentioned that he was using this inside a loop..thats what i was saying that his code was working good..:)
     
    ankit_frenz, Dec 18, 2010 IP
  9. dpacmittal

    dpacmittal Well-Known Member

    Messages:
    155
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    103
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #9
    The output he was getting implied he was using it inside a loop or subsequently one after another.
     
    dpacmittal, Dec 18, 2010 IP