Jump to content
alexarpad2003

Nu inteleg functia

Recommended Posts

Posted

Am asa :

<?php

function get_euro()

{

$tgt='http://www.bancatransilvania.ro/istoric_valuta.php?limba=0&valuta=2';

@$x=file_get_contents($tgt,'FILE_TEXT',NULL,0,1250);

@$x_exp=explode('<td>',$x);

@$x2=explode(' ',$x_exp[7]);

@$x_final=explode('>',$x2[10]);

@$EUR=(float)$x_final[1];

return $EUR;

}

?>

Asi dori sa-mi returneze cursul de la bnr din pagina Banca Transilvania .

O idee ?

Posted (edited)

ti-o fac eu. revin cu un edit.

edit:

<?php

function get_string_between($string, $start, $end){
$string = " xxx".$string."zzz";
$ini = strpos($string,$start);
if ($ini == 0) return "";
$ini += strlen($start);
$len = strpos($string,$end,$ini) - $ini;
return substr($string,$ini,$len);
}

$x = file_get_contents('http://www.bancatransilvania.ro/istoric_valuta.php?limba=0&valuta=2','FILE_TEXT',NULL,0,1250 );
$cursuri = explode("</td><td valign=middle class=\"scris_12\">",$x);

$curs = $cursuri[2];
$cumparare = $cursuri[3];
$vanzare = get_string_between($cursuri[4], "xxx", "</td></tr><tr><td>");

echo $curs ." - ". $cumparare ." - ". $vanzare;

?>

Edited by jesus

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...