ファイルの内容があなたが説明したとおりであると仮定すると:
var now = (new Date() - 0);
other_var = 'Whats up';//how to pull the value of the other_var which is 'Whats Up'
key.embed();
次に、次を使用することをお勧めします。
$data = file_get_contents("javascriptfile.js"); //read the file
//create array separate by new line
//this is the part where you need to know how to navigate the file contents
//if your lucky enough, it may be structured statement-by-statement on each
$contents = explode("\n", $data);
$interestvar = "other_var";
$interestvalue = "";
foreach ($contents as $linevalue)
{
//what we are looking for is :: other_var = 'Whats up';
//so if "other_var" can be found in a line, then get its value from right side of the "=" sign
//mind you it could be in any of the formats 'other_var=xxxxxx', 'other_var= xxxxxx', 'other_var =xxxxxx', 'other_var = xxxxxx',
if(strpos($linevalue,$interestvar." =")!==false){
//cut from '=' to ';'
//print strpos($linevalue,";");
$start = strpos($linevalue,"=");
$end = strpos($linevalue,";");
//print "start ".$start ." end: ".$end;
$interestvalue = substr($linevalue,$start,$end-$start);
//print $interestvalue;
break;
}
}
if($interestvalue!=="")
print "found: ".$interestvar. " of value : ".$interestvalue;