Results 1 to 3 of 3

Thread: [resolved] split string to array, then foreach

Threaded View

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jul 2004
    Posts
    121

    Resolved [resolved] split string to array, then foreach

    Hello all.

    I am posting a string, $_POST['hotels'], which is: "2,33,22,20,21"

    I would like to split that string, at the comma, into an array, converting each to a number, then doing a foreach.

    I was thinking:
    Code:
    $hotels = split(',',$_POST['hotels']);
    
    foreach ($hotels as $x) {
    	//convert $x to a number
    	//do something with $x
    }
    But I'm not doing it right.
    Any help is greatly appreciated.
    Many thanks.
    Last edited by solitario; May 27th, 2005 at 02:52 PM.

Posting Permissions

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



Click Here to Expand Forum to Full Width