You can use a regular expression. This code will return the room id in your example.
<?php
$html = '
<script type="text/javascript">
var base_url = "http://www.exampleurl.com/";
var room_id = "357"; //I want to get the value of room_id
var selected_room_button = "";
</script>';
$pattern = '/var room_id = "(.*)";/';
preg_match($pattern, $html, $matches);
$room_id = $matches[1];
But there is no general solution as a variable may have been defined twice, or have been defined in different scopes.
If you don't need to extract other content beside the row_id I would see no reason for using a HTML parser. It would just slow down things. Also please expect the HTML parser not being a Javascript parser! The HTML parser would just being used to extract the unparsed content between <script>
</script>
tags - as a string. You would need a regex again to extract the row_id.