Ich entwickle einen Währungsumrechner mit PHP und Google Finanzen als Teil meiner System-Design-Klasse.preg_match Fehler, Währungsumrechner, undefined Offset: 1
Können Sie mir helfen, den Fehler zu beheben:
"Notice: Undefined offset: 1"? Hier
ist der Code:
HTML
<form action="" method="POST">
Amount:
<input type="text" name="amount" /><br/><br/>
From:
<input type="text" name="from" /><br/><br/>
To:
<input type="text" name="to" /><br/><br/>
<input type="submit" id="convert" name="convert"/>
</form>
PHP
<?php
function currency_convert($amount, $from, $to){
$url='https://www.google.com/finance/converter?a='.$amount.'&from='.$from.'&to='.$to;
$data = file_get_contents($url);
preg_match("/<span class=bld>(.*)<\/span>/",$data,$converted);
echo $converted[1];
}
if(isset($_POST['convert'])){
$amount=$_POST['amount'];
$from=$_POST['from'];
$to=$_POST['to'];
currency_convert($amount, '$from', '$to');
}
?>
muss nicht zitiert werden "$ from", "$ to" – Ghost
Hi @ Ghost. Dieses Gefühl, wenn Sie von einzelnen Zitaten gepackt werden. Vielen Dank. –