<?php 

$url = file_get_contents('http://flowerswholesale.ru/price/4.mxl');

$a = file('http://flowerswholesale.ru/price/4.mxl');

print_r($a);

unset($a[0],$a[1],$a[2],$a[3],$a[4],$a[5],$a[6],$a[7],$a[8]);

$file = '/home/john/www/flowerswholesale.ru/price/4.mxl';
$xml = simplexml_load_string($file);
$array = (array)$xml;
print_r($url);

//$b = array_splice($a, 0, 9);

//preg_match_all('/(\d+)/', $a[9], $a2);

$a2=[];

foreach ($a AS $a0) 
{
preg_match_all('~(\d+)?(?(1)|\D+)~', $a0, $a2[]);

//print_r($a[9]);
}

//print_r($a2);

$rosken='Роза 40 Кения';
$req = '';
$reqw = '';
$reqr = '';
$tros = '';
$tulip = '';
$tros='';
$url ='/home/john/www/flowerswholesale.ru'; 

$array = array(
	array($rosken,7,0,$url.'/ssi/price/7ke.html'),
	array($rosken,9,0,'/ssi/price/9ke.html'),
	array($rosken,11,0,'/ssi/price/11ke.html'),
	array($rosken,15,0,'/ssi/price/15ke.html'),
	array($rosken,25,0,'/ssi/price/25ke.html'),
	array($rosken,51,0,'/ssi/price/51kenya.html'),
	array($rosken,51,0,'/ssi/price/101kenya.html'),
	array($rosken,101,0,'/ssi/price/51kenya-red.html'),
	array($rosken,101,0,'/ssi/price/101kenya-red.html'),
    array($rosken,1,0,'/ssi/price/kenya-promo.html'),
	array($rosken,1,0,'/ssi/price/kenya-red.html'),
	array($rosken,1,0,'/ssi/price/kenya-white.html'),
	array($rosken,1,0,'/ssi/price/kenya-promo.html'),
	//array('Роза 35-40 см Кения микс',1,0,'/ssi/price/kenya-red.html'),
	//array('Роза 35-40 см Кения микс',1,0,'/ssi/price/kenya-white.html'),
	array('Альстромерия',1,0,'/ssi/price/alstr.html'),

	array($req,7,0,'/ssi/price/7eq.html'),
	array($req,9,0,'/ssi/price/9eq.html'),
	array($req,11,0,'/ssi/price/11eq.html'),
	array($req,15,0,'/ssi/price/15eq.html'),
	array($req,25,0,'/ssi/price/25equador.html'),
	array($req,51,0,'/ssi/price/51equador.html'),
	array($req,101,0,'/ssi/price/101equador.html'),
	array($req,25,0,'/ssi/price/25equador-red.html'),
	array($req,25,0,'/ssi/price/25equador-white.html'),
    array($req,51,0,'/ssi/price/51equador-red.html'),
	array($req,51,0,'/ssi/price/51equador-white.html'),
	array($req,101,0,'/ssi/price/101equador-red.html'),
	array($req,101,0,'/ssi/price/101equador-white.html'),
	array($req,1,0,'/ssi/price/ecuador-white-promo.html'),
    array($req,1,0,'/ssi/price/ecuador-promo.html'), // 50см вероятно
	array($req,1,0,'/ssi/price/ecuador-red-promo.html'),
	array($req,1,0,'/ssi/price/eq-promo.html'),

	array($tulip,1,0,'/ssi/price/tulip-promo.html'),

);

//print_r($array);

foreach ($a2 AS $a3)
{
foreach ($array AS $ar)
{ 
	//print_r($a3[0]);
	//print_r($ar[0]);
if ($a3[0] == $ar[0])
{ 
$z=$a3[1]*$ar[1];
file_put_contents($ar[3], $z);
//print_r($ar[3]);
}}}

//print_r('done');

/*
preg_match_all('/<TD BGCOLOR=#808080>([^:]+)<TD VALIGN=TOP><FONT SIZE=4><B>/', $url, $matches);

//var_dump($matches[1][0]);

preg_match('/<TD>&nbsp([^:]+)\/TR>/', $matches[1][0], $matches2);

//preg_replace('<tr>'," ",$matches2[0]);

$table = str_replace("<TD>&nbsp;", "", $matches2[0]);

$table2 = str_replace("ALIGN=RIGHT", "ALIGN=CENTER", $table);

//var_dump($table);

echo $table2;

//var_dump($matches2[0]);

//var_dump($matches[0][1]);

//echo $matches[1][0];
//echo $matches;

//$price = $matches[1][0];

//var_dump($matches[1]);

print_r($matches[0]);

foreach ( $matches[0] AS $item )

{ //var_dump($item);

preg_match_all('/<FONT SIZE=2>([\S\s]+)<\/FONT>/', $item, $item0);

#print_r($item);

preg_match_all('/(\d+)/', $item, $item2);
print_r($item2);

//print_r($item2);
//var_dump($item2);
/*
echo '
 <tr>
  <td>'.$item0[0][0].'</td>
  <td>'.$item2[0][1].'</td>
  <td>'.$item2[0][2].'</td>
 </tr>';
**/
//echo '<tr>'.$item2[0][2].'</br></tr>';

//echo $item2[1];
//preg_match_all('/<TD ALIGN=RIGHT VALIGN=CENTER>([\S\s]+?)\n/', $item, $item3);

//var_dump($item3);

//echo $item3[0][0];

//echo '<td>'.$item3[1][0].'</td>';

//}



//echo($price);

//echo $price;

//var_dump($price);

?>

