Upvote:-1
What country are you from? If you are a citizen of countries on the 30 day Visa exemption on Arrival list, then your itinerary as stated should be fine. Arriving in Thailand by air gets you a 30 day visa exemption; arriving via land gets a 15 day visa exemption (even for citizens of countries on the 30 day Visa exemption on Arrival list).
Upvote:2
You will be fine if you're from a country that's on the 30-day exemption list. Especially since you are flying.
Thailand used to have two lists of 30-day exemption countries: countries that would get 30 days whatever the means of transportation (there were only a few countries, 9 or 10. France was among those countries, and I always got 30 days when walking into Thailand in places like Nongkhai or Poipet), and a larger list of countries that would get 30 days for an arrival by air, and 15 days for an arrival by land or sea. The idea was to put financial pressure on people from countries that were statistically more enclined to live in Thailand on tourist visas.
Late 2016, Thailand merged both lists into a single 30-day exemption list, for arrivals by any transportation. The catch is that you can get the 30-day exemption for arrival by land or sea only twice a year. After that, you need a visa if you plan to do a border run by land or sea. See https://en.wikipedia.org/wiki/Visa_policy_of_Thailand#30_days_exemption_(44_nations)
Holders of normal passports of the following countries are granted visa-free travel to Thailand for a period of up to 30 days. The exemption is granted at most twice in a calendar year when entering overland or via a sea border but there is no limitation when entering by air.
Back to your case. For example, last month I flew to Bangkok, got 30 days, then, after 2 days, flew to Phnom Penh where I stayed 2 days, flew back to Bangkok, where I got another 30 days. I go every month to Bangkok, and it always works out this way.