Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

Carcleo

open dir e exclusão

Recommended Posts

Pessoal, estou um tanto pérdido e preciso de uma força aqui

 

Preciso arranjar uma forma de varrer uma pasta e ver quais imagens (só tem imagens la) que tem la e depois ncomparar com uma lista que vem do MySql.

 

Depois, as nimagens que estiverem a mais na pasta que não tem na tabela do MySql, excluir essa imagem da pasta.

 

Como fazer isso?

Compartilhar este post


Link para o post
Compartilhar em outros sites

Compartilhar este post


Link para o post
Compartilhar em outros sites

Ok

agora, fiz assim:

<?php
$dir = "imagens/upload/venda/miniaturas/";

// Abre um diretorio conhecido, e faz a leitura de seu conteudo
if (is_dir($dir)) {
    if ($dh = opendir($dir)) {
        while (($file = readdir($dh)) !== false) {
           $NomesFotos[] = $file;
        }
        closedir($dh);
    }
}
$NomeTodasFotos = implode(';',$NomesFotos);
print $NomeTodasFotos;
?>
[/oode]
isso esta me retornando assim: (só tem duas fotos no diretorio)
[code]
.;..;2a3568999b212ce219fdae211f5a3f09.JPG;ff61f5f32cd8cf6ae950d1a0525c6609.JPG
[/code]
Minhas duvidas
Esse inicio|; 
[code]
.;..;
[/code]
Pode ser tirado com substring ou pode acontecer de esse inicio, dependendo o diretorio ou do numero de imagens pode mudar?

Olhe a ideia do codigo:
[code]

<?php 
header('Content-Type: text/html; charset=utf-8');
include ("global/funcoes_php/var.php");
include("global/funcoes_php/conexao.php"); 
$MySQL = new TMySQL();
$MySQL->connect($host, $db, $user, $pass);
?>

<?php
function varre ($dir) {
// Abre um diretorio conhecido, e faz a leitura de seu conteudo
if (is_dir($dir)) {
    if ($dh = opendir($dir)) {
        while (($file = readdir($dh)) !== false) {
           $NomesFotos[] = $file;
        }
        closedir($dh);
    }
}
$NomeTodasFotos = implode(';',$NomesFotos);
$NomeTodasFotos = substr($NomeTodasFotos, 5);
return $NomeTodasFotos;
} 
?>
<!--//////////////////////////////-->
<?
   $sql=mysql_query("
	    select 
			ImoveisCadastroVenda.Foto, 
			ImoveisCadastroVenda.Foto2, 
			ImoveisCadastroVenda.Foto3, 
			ImoveisCadastroVenda.Foto4, 
			ImoveisCadastroVenda.Foto5, 
			ImoveisCadastroVenda.Foto6, 
			ImoveisCadastroVenda.Foto7, 
			ImoveisCadastroVenda.Foto8,
			ImoveisCadastroVenda.Foto9, 
			ImoveisCadastroVenda.Foto10, 
		from 
		   ImoveisCadastroVenda 
		        ");
		$dir = "imagens/upload/venda/miniaturas/";
		while (list($Foto1,$Foto2,$Foto3,$Foto4,$Foto5,$Foto6,$Foto7,$Foto8,$Foto9,$Foto10) = mysql_fetch_row($sql)){
			
//aqui vai a comparaçao
		}
?>

Compartilhar este post


Link para o post
Compartilhar em outros sites

Entendi.

Porem, pode ser que va imagens gif, png e não ha como controlar isso.

Então agora ja consegui criar uma string com os nomes vindos do banco e do diretorio separados por ; em duas variaveis.

 

Agora falta ver qual imagem nesta em uma e não esta na outra e criar a funçao para excluir essa imagem da pasta.

Segue o que eu ja consegui

 

<?php 
header('Content-Type: text/html; charset=utf-8');
include ("global/funcoes_php/var.php");
include("global/funcoes_php/conexao.php"); 
$MySQL = new TMySQL();
$MySQL->connect($host, $db, $user, $pass);
?>

<?php
function varre ($dir) {
// Abre um diretorio conhecido, e faz a leitura de seu conteudo
if (is_dir($dir)) {
    if ($dh = opendir($dir)) {
        while (($file = readdir($dh)) !== false) {
           $NomesFotos[] = $file;
        }
        closedir($dh);
    }
}
$NomeTodasFotos = implode(';',$NomesFotos);
$NomeTodasFotos = substr($NomeTodasFotos, 5);
return $NomeTodasFotos;
} 

   $sql=mysql_query("
	    select 
			ImoveisCadastroVenda.Foto, 
			ImoveisCadastroVenda.Foto2, 
			ImoveisCadastroVenda.Foto3, 
			ImoveisCadastroVenda.Foto4, 
			ImoveisCadastroVenda.Foto5, 
			ImoveisCadastroVenda.Foto6, 
			ImoveisCadastroVenda.Foto7, 
			ImoveisCadastroVenda.Foto8,
			ImoveisCadastroVenda.Foto9, 
			ImoveisCadastroVenda.Foto10 
		from 
		   ImoveisCadastroVenda 
		        ") or die("iiiiiiiii");
		
		while (list($Foto1,$Foto2,$Foto3,$Foto4,$Foto5,$Foto6,$Foto7,$Foto8,$Foto9,$Foto10) = mysql_fetch_row($sql)){
			$NomesFotos2[] = $Foto1.";".$Foto2.";".$Foto3.";".$Foto4.";".$Foto5.";".$Foto6.";".$Foto7.";".$Foto8.";".$Foto9.";".$Foto10;
//aqui vai a comparaçao
		}
		
		$NomeTodasFotos2 = implode(';',$NomesFotos2);
        $NomeTodasFotos2 = substr($NomeTodasFotos2, 5);
		print $NomeTodasFotos2."<P>";
		$dir = "imagens/upload/venda/miniaturas/";
		print varre($dir)."<P>";		

?>

Compartilhar este post


Link para o post
Compartilhar em outros sites

hum... acho que trabalhar com arrays é bem mais simples, fácil e rápido..

 

algo como in_array, ou array_dif(ou algo assim..)

http://www.php.net/manual/en/ref.array.php

Compartilhar este post


Link para o post
Compartilhar em outros sites

Utilize a flag GLOB_BRACE no segundo parâmetro de glob() para casar mais tipos de arquivos no padrão.

Algo assim:

 

$dir = 'imagens/upload/venda/miniaturas/*.{jpg,gif,png}';
$NomeTodasFotos = glob( $dir, GLOB_BRACE );

print_r( $NomeTodasFotos );

Compartilhar este post


Link para o post
Compartilhar em outros sites

Não, não

 

Essa parte eu ja fiz.

Agora tenho duas variaveis com os nomes das imagens que vem do banco em uma variavel. Sendo que os nomes são separadas por ';':

$NomeTodasFotos2 = implode(';',$NomesFotos2);
$NomeTodasFotos2 = substr($NomeTodasFotos2, 5);
E tambem tenho uma variavel com os nomes das imagens que estão na pasta tambem separadas por ';':

$dir = "imagens/upload/venda/miniaturas/";
$NomeTodasFotos = varre($dir)
Conforme a função varre acima.

Agora preciso ver quais nomes de fotos estão na variavel $NomeTodasFotos2 e que não estão na variavel $NomeTodasFotos e excluir elas na pasta.

 

Como faço isso?

 

Tentei fazer assim mas não deu resultado algum:

 

preg_match($NomeTodasFotos2, varre($dir), $matches, PREG_OFFSET_CAPTURE);
print_r($matches);

To com uma previa do resultado das variaveis aqui:

Ve se ajuda:


$a= "2a3568999b212ce219fdae211f5a3f09.JPG;ff61f5f32cd8cf6ae950d1a0525c6609.JPG;ff61f5f32cd8cf6ae950d1a0525c6609.JPG";
$b= "2a3568999b212ce219fdae211f5a3f09.JPG;c92733e083bf8ed3b676d8def9a.JPG;0bb769196b966a479b306682598962db.JPG;b7356b5afd6d70a77c50792d2304e322.JPG;c1f9e5b5f5675aba30aade2128b515d9.JPG;6c833a8a61a8dc829683df49adfae65b.JPG;424a8e0242b46bd723a3a1a7d245143f.JPG;f52efac281c67e302839df51b90231e8.JPG;9f4bfd6c9a6b61b93d16eae0ccde0434.JPG;62d6a89ca80dc2d8371db5b351e7c537.JPG;bc4ec2c6b65abcf0e6b52300fd568220.JPG;922cbe9965024100f74d692555815185.JPG;46f55d4fbf6631a28704329486ab231d.JPG;2d530452ad9ed25d3de640e51706368f.JPG;0645a0f8569992f112e7176c9c5f00bf.JPG;730f53625d7dcf1039dcdbc55a4d45db.JPG;bf3dfddb558ec510ce4ba2da85a90bf3.JPG;b8a855d0689e6afd8014954cf751a0c8.JPG;01a3b6edf6ef1a9d7f075dbdafcb46d5.JPG;1b8abc0f9d025d7d9839d6360805a7d8.JPG;dda8956c6414440c5249aa599ce8e8d3.JPG;6f6c6a8883eba477e593309d27d5869e.JPG;b1e00af98c6eee5dc80923948f77c31b.JPG;;;;;;;;;54da631618a2c06779c042fa7e869298.JPG;1998e1fa94d1bcfbcc510e9235408d92.JPG;4edda823ec38c38c85cc7699152047d3.JPG;d8d63d9183913317d4f64effdce2b258.JPG;351c3c03da61cca31b136b21d78c15c5.JPG;1cccc26be7e8270e29dd3e30f6cc8ed5.JPG;032fe1637da844c27011b7ec18b3f1e5.JPG;1d1b6bda0b93e414d9d3884f2352c98a.JPG;9822be06eb108538d6c02a2bd999ffd8.JPG;9dadeda97d123651804163ba1674c0ac.JPG;ff61f5f32cd8cf6ae950d1a0525c6609.JPG;83777b4d592aedfb13c2af7f8ddfef3e.JPG;40bc639264ab98f2883697f29b02cc25.JPG;ccc83f1193898c8aa6404e8e6d2d2a8f.JPG;8c8ebc03bd69233c9ec0bad4423a8828.JPG;;;;;;87e9e7d0f0d7c825318aa2f9bfef429f.JPG;c9cc2edb540b718f520e4fa791f75c33.JPG;dacf3cfa8262a939138f93c3ec0c0890.JPG;97745323890c0153581ebf9f767b934e.JPG;4b86a19a7c5b5802f55ed3d6e5487dea.JPG;4460ed16255089dd570c44c8900a1740.JPG;4261948cbcafa448ecc6304a308de405.JPG;b54eb5995e31d4a589ddcc7fce5c12dd.JPG;6990dde9d86199a7704d9a3dbb21478e.JPG;83e16a115c41b0df2dd3cd856d8512ab.JPG;356e80715e8afea7fb29735760df9c26.JPG;8d94860d5b4e2d35b7759fb6063e8cc7.JPG;8bb8c5a1609de63cdb02336d05e5ebf3.JPG;7f9d10d206b1380d59b5ec27b298614f.JPG;a5be89a35e16145196a71890eb0218af.JPG;6497e3e9462d24a9f67cb590d1d1ad15.JPG;ad6ac0d82bbf2209c6e1931145efb682.JPG;d1e06a1cf68d2fb13010f73fb794dc6c.JPG;4e80672b7f64d634bc850034ef8a76ab.JPG;a0780acf52eb42aba7d31a422f35030d.JPG;38a30d48e560d12008b2cbd41d330525.JPG;811b1da20baf0b2091b69661fbe5e365.JPG;a416abdd5f921f2433133e21d89e4f3c.JPG;815d53677e82952c8a16665366c29ada.JPG;0e840a2d8c1cec7a50225c6c1ccd3b6d.JPG;c9e1a150b22c30eb5551077f19ca9ec7.JPG;0e5764ba367440dd2ce3f80373cbeaf1.JPG;855db7a987c513a3ce87cdc08136b2b8.JPG;5247d5e90e6258eb43f8ffc48237ca0d.JPG;;2abc37e7eec9f18fc4110214db7d0782.JPG;5e6437167928842d8f057634cec187da.JPG;76d0283314413dcb7fda2e3536819d3b.JPG;de9d597e9af6996be36ff03410c007a8.JPG;ad9e2e10cb9417ee8412ddae3544b213.JPG;be56e271479e6ace57bfcb57deaa2e82.JPG;;;;;a5ee7af3587819537d3f3ec57b67c360.JPG;58ed96533f0260a5cbdece2b452c8ace.JPG;30ce6023b854e2d9bfc3bce3b4a8450d.JPG;711f1a40732b20af24c398e59ab1424c.JPG;f0c24d879cc0d25ec1aec161e9decc6d.JPG;;;;;;a431f2c37ebbdff1bdc73dbeddf1a272.JPG;1891ced06048c08c5821f6f4d1271e8d.JPG;8c730c247351581cc4a7f60c6ac34e74.JPG;3b343e566ed497ca83a0e3ce0b3dba4c.JPG;b3845fe870c7f8be34765b6bd7d13fd9.JPG;5a6e50cfec38613b425d4c5bbc38de93.JPG;cf29cda2add9468fc21b92a27c410ed2.JPG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ";
preg_match($b, $a, $matches2, PREG_OFFSET_CAPTURE);
print_r($matches2);
Isso não imprime nada na tela e como podem ver a primeira imagem nas duas variaveis é mesma.

Compartilhar este post


Link para o post
Compartilhar em outros sites

TA ACHO QUE AGORA VAI DAR

 

SÓ QUE EM UMA DAS MINHAS ARRAYS ESTA RETORNANDO ASSIM:

Array
(
    [0] => b813dc92733e083bf8ed3b676d8def9a.JPG;0bb769196b966a479b306682598962db.JPG;b7356b5afd6d70a77c50792d2304e322.JPG;c1f9e5b5f5675aba30aade2128b515d9.JPG;6c833a8a61a8dc829683df49adfae65b.JPG;424a8e0242b46bd723a3a1a7d245143f.JPG;f52efac281c67e302839df51b90231e8.JPG;9f4bfd6c9a6b61b93d16eae0ccde0434.JPG;62d6a89ca80dc2d8371db5b351e7c537.JPG;bc4ec2c6b65abcf0e6b52300fd568220.JPG
    [1] => 922cbe9965024100f74d692555815185.JPG;46f55d4fbf6631a28704329486ab231d.JPG;2d530452ad9ed25d3de640e51706368f.JPG;0645a0f8569992f112e7176c9c5f00bf.JPG;730f53625d7dcf1039dcdbc55a4d45db.JPG;bf3dfddb558ec510ce4ba2da85a90bf3.JPG;b8a855d0689e6afd8014954cf751a0c8.JPG;01a3b6edf6ef1a9d7f075dbdafcb46d5.JPG;1b8abc0f9d025d7d9839d6360805a7d8.JPG;dda8956c6414440c5249aa599ce8e8d3.JPG
    [2] => 6f6c6a8883eba477e593309d27d5869e.JPG;b1e00af98c6eee5dc80923948f77c31b.JPG;;;;;;;;
    [3] => 54da631618a2c06779c042fa7e869298.JPG;1998e1fa94d1bcfbcc510e9235408d92.JPG;4edda823ec38c38c85cc7699152047d3.JPG;d8d63d9183913317d4f64effdce2b258.JPG;351c3c03da61cca31b136b21d78c15c5.JPG;1cccc26be7e8270e29dd3e30f6cc8ed5.JPG;032fe1637da844c27011b7ec18b3f1e5.JPG;1d1b6bda0b93e414d9d3884f2352c98a.JPG;9822be06eb108538d6c02a2bd999ffd8.JPG;9dadeda97d123651804163ba1674c0ac.JPG
    [4] => b1fcce3c5b6ab08fcc53705531a64ecb.JPG;83777b4d592aedfb13c2af7f8ddfef3e.JPG;40bc639264ab98f2883697f29b02cc25.JPG;ccc83f1193898c8aa6404e8e6d2d2a8f.JPG;8c8ebc03bd69233c9ec0bad4423a8828.JPG;;;;;
    [5] => 87e9e7d0f0d7c825318aa2f9bfef429f.JPG;c9cc2edb540b718f520e4fa791f75c33.JPG;dacf3cfa8262a939138f93c3ec0c0890.JPG;97745323890c0153581ebf9f767b934e.JPG;4b86a19a7c5b5802f55ed3d6e5487dea.JPG;4460ed16255089dd570c44c8900a1740.JPG;4261948cbcafa448ecc6304a308de405.JPG;b54eb5995e31d4a589ddcc7fce5c12dd.JPG;6990dde9d86199a7704d9a3dbb21478e.JPG;83e16a115c41b0df2dd3cd856d8512ab.JPG
    [6] => 356e80715e8afea7fb29735760df9c26.JPG;8d94860d5b4e2d35b7759fb6063e8cc7.JPG;8bb8c5a1609de63cdb02336d05e5ebf3.JPG;7f9d10d206b1380d59b5ec27b298614f.JPG;a5be89a35e16145196a71890eb0218af.JPG;6497e3e9462d24a9f67cb590d1d1ad15.JPG;ad6ac0d82bbf2209c6e1931145efb682.JPG;d1e06a1cf68d2fb13010f73fb794dc6c.JPG;4e80672b7f64d634bc850034ef8a76ab.JPG;a0780acf52eb42aba7d31a422f35030d.JPG
    [7] => 38a30d48e560d12008b2cbd41d330525.JPG;811b1da20baf0b2091b69661fbe5e365.JPG;a416abdd5f921f2433133e21d89e4f3c.JPG;815d53677e82952c8a16665366c29ada.JPG;0e840a2d8c1cec7a50225c6c1ccd3b6d.JPG;c9e1a150b22c30eb5551077f19ca9ec7.JPG;0e5764ba367440dd2ce3f80373cbeaf1.JPG;855db7a987c513a3ce87cdc08136b2b8.JPG;5247d5e90e6258eb43f8ffc48237ca0d.JPG;
    [8] => 2abc37e7eec9f18fc4110214db7d0782.JPG;5e6437167928842d8f057634cec187da.JPG;76d0283314413dcb7fda2e3536819d3b.JPG;de9d597e9af6996be36ff03410c007a8.JPG;ad9e2e10cb9417ee8412ddae3544b213.JPG;be56e271479e6ace57bfcb57deaa2e82.JPG;;;;
    [9] => a5ee7af3587819537d3f3ec57b67c360.JPG;58ed96533f0260a5cbdece2b452c8ace.JPG;30ce6023b854e2d9bfc3bce3b4a8450d.JPG;711f1a40732b20af24c398e59ab1424c.JPG;f0c24d879cc0d25ec1aec161e9decc6d.JPG;;;;;
    [10] => a431f2c37ebbdff1bdc73dbeddf1a272.JPG;1891ced06048c08c5821f6f4d1271e8d.JPG;8c730c247351581cc4a7f60c6ac34e74.JPG;3b343e566ed497ca83a0e3ce0b3dba4c.JPG;b3845fe870c7f8be34765b6bd7d13fd9.JPG;5a6e50cfec38613b425d4c5bbc38de93.JPG;cf29cda2add9468fc21b92a27c410ed2.JPG;;;
    [11] => 007dcab84666a33e27908d8031f0c2eb.JPG;a8027741c5cd502d0f53c1709935c7f7.JPG;14c5ca92b26682121feb8327eeb2181e.JPG;16fe71ee2ece654cb6fc1e9344395fa3.JPG;d3ffa80c4ae59b367fc6671cc75436ad.JPG;f7dd2f406e8929f488a901b29d72ba38.JPG;f2497dc12c61c8d3fa6d726a775a5a59.JPG;d16dd48802d6d7adf4c8478b36461d3f.JPG;e083a556033fb4f7a7b7b746d547864f.JPG;f73a9e956c3812900154a43dcf859e2e.JPG
    [12] => 0f72cecf3d1b485544eef9964458cded.JPG;2f1e5010518f49492acb7fc46fe6538a.JPG;63817385fd809e3fd51157367815a146.JPG;e0150bdbeef20a5b71fa673293fabc3c.JPG;2ef98cb09a17411eec1fda7e5a247c38.JPG;fe41e475fa39d4ab61a7cc6df37abb77.JPG;2331a215016cb84b426e7a8c378070f6.JPG;943459eb6234abb60960ad89abe42298.JPG;1a9a99a8e6bc125f68d8238f2cfb2ce0.JPG;200ff90afcb6c276beab6c7e32e4417d.JPG
    [13] => 0a1f350779f05dd6aabe69c6464425c9.JPG;1c76b10f2d2bc5f8c88d4689e8551bf2.JPG;ecee0b7945c919716f935029d06e2a0b.JPG;6d2dc07b3ded08984b61ac895bc0a6ca.JPG;dc41f62c33908866cfb0407374a740c4.JPG;d05164a3a8a0a5a52632a1de97e77e98.JPG;c5939a684154ef1cf69cf25b92b0cda4.JPG;35a5b08ec0837feb66b35e605f2ce209.JPG;19ffdb216d56164966a67ea0957621b2.JPG;bbc62c3066dd3efb892ae92990131b89.JPG
    [14] => 2257769ca057ea83f8198d14b434e1b5.JPG;5530fbe884b04f9b3b9826b1f5febd36.JPG;7080341a7d9d3a3091bb2eb3d37b13ff.JPG;073fea87b2742f95e65d676997d944af.JPG;;;;;;
    [15] => d6dc0ab55bc079ba8482fb9fb8305b8a.JPG;;;;;;;;;
)
E A OUTRA ESTA RETORNANDO ASSIM:


Array
(
    [0] => 007dcab84666a33e27908d8031f0c2eb.JPG
    [1] => 01a3b6edf6ef1a9d7f075dbdafcb46d5.JPG
    [2] => 01b173dfb6a5fe2364552b732ff538e9.JPG
    [3] => 032fe1637da844c27011b7ec18b3f1e5.JPG
    [4] => 03c8304b29a483d2490e039a356227df.JPG
    [5] => 04b4e9973f4bea00e159f216e794dbf6.JPG
    [6] => 0611ac57418ee227b8dca345f2670f6e.JPG
    [7] => 0645a0f8569992f112e7176c9c5f00bf.JPG
    [8] => 073fea87b2742f95e65d676997d944af.JPG
    [9] => 0a1f350779f05dd6aabe69c6464425c9.JPG
    [10] => 0bb769196b966a479b306682598962db.JPG
    [11] => 0c071d2b66dfc3b9f38ac3253fdbfcb8.JPG
    [12] => 0e5764ba367440dd2ce3f80373cbeaf1.JPG
    [13] => 0e840a2d8c1cec7a50225c6c1ccd3b6d.JPG
    [14] => 0f72cecf3d1b485544eef9964458cded.JPG
    [15] => 14afc903a7112dab1a0cc7839125b58f.JPG
    [16] => 14c5ca92b26682121feb8327eeb2181e.JPG
    [17] => 16fe71ee2ece654cb6fc1e9344395fa3.JPG
    [18] => 1891ced06048c08c5821f6f4d1271e8d.JPG
    [19] => 1998e1fa94d1bcfbcc510e9235408d92.JPG
    [20] => 19ffdb216d56164966a67ea0957621b2.JPG
    [21] => 1a9a99a8e6bc125f68d8238f2cfb2ce0.JPG
    [22] => 1b8abc0f9d025d7d9839d6360805a7d8.JPG
    [23] => 1c76b10f2d2bc5f8c88d4689e8551bf2.JPG
    [24] => 1cccc26be7e8270e29dd3e30f6cc8ed5.JPG
    [25] => 1d1b6bda0b93e414d9d3884f2352c98a.JPG
    [26] => 200ff90afcb6c276beab6c7e32e4417d.JPG
    [27] => 2257769ca057ea83f8198d14b434e1b5.JPG
    [28] => 2331a215016cb84b426e7a8c378070f6.JPG
    [29] => 2abc37e7eec9f18fc4110214db7d0782.JPG
    [30] => 2d530452ad9ed25d3de640e51706368f.JPG
    [31] => 2ef98cb09a17411eec1fda7e5a247c38.JPG
    [32] => 2f1e5010518f49492acb7fc46fe6538a.JPG
    [33] => 300cbc94c061e7cac391ce18e4bb2d28.JPG
    [34] => 30ce6023b854e2d9bfc3bce3b4a8450d.JPG
    [35] => 33414e7da806ac1dde8e4a5ebc79db1a.JPG
    [36] => 3410d1ac639595be7dff9241b8f4ff47.JPG
    [37] => 345fc952af8f4f3c471e766c1c31bae2.JPG
    [38] => 351c3c03da61cca31b136b21d78c15c5.JPG
    [39] => 356e80715e8afea7fb29735760df9c26.JPG
    [40] => 35a5b08ec0837feb66b35e605f2ce209.JPG
    [41] => 38a30d48e560d12008b2cbd41d330525.JPG
    [42] => 3b343e566ed497ca83a0e3ce0b3dba4c.JPG
    [43] => 3b76e7930236f1f6400d326549c28c3f.JPG
    [44] => 40bc639264ab98f2883697f29b02cc25.JPG
    [45] => 40d23f9b1fe4c3597f46d218b24ccde2.JPG
    [46] => 422d227412376b01ed02a3ad6a08252d.JPG
    [47] => 424a8e0242b46bd723a3a1a7d245143f.JPG
    [48] => 4261948cbcafa448ecc6304a308de405.JPG
    [49] => 4460ed16255089dd570c44c8900a1740.JPG
    [50] => 4503bd094d59e53de3ce39dbb4362dd4.JPG
    [51] => 45be13cefc69da9eeaa78a3ff00d397a.JPG
    [52] => 46f55d4fbf6631a28704329486ab231d.JPG
    [53] => 4b86a19a7c5b5802f55ed3d6e5487dea.JPG
    [54] => 4e80672b7f64d634bc850034ef8a76ab.JPG
    [55] => 4edda823ec38c38c85cc7699152047d3.JPG
    [56] => 51b7c0470958b45f7b3b04aeeac9e3a1.JPG
    [57] => 5247d5e90e6258eb43f8ffc48237ca0d.JPG
    [58] => 54da631618a2c06779c042fa7e869298.JPG
    [59] => 5530fbe884b04f9b3b9826b1f5febd36.JPG
    [60] => 58ed96533f0260a5cbdece2b452c8ace.JPG
    [61] => 5a6e50cfec38613b425d4c5bbc38de93.JPG
    [62] => 5e6437167928842d8f057634cec187da.JPG
    [63] => 62d6a89ca80dc2d8371db5b351e7c537.JPG
    [64] => 63817385fd809e3fd51157367815a146.JPG
    [65] => 6497e3e9462d24a9f67cb590d1d1ad15.JPG
    [66] => 6990dde9d86199a7704d9a3dbb21478e.JPG
    [67] => 6c833a8a61a8dc829683df49adfae65b.JPG
    [68] => 6d2dc07b3ded08984b61ac895bc0a6ca.JPG
    [69] => 6f6c6a8883eba477e593309d27d5869e.JPG
    [70] => 7080341a7d9d3a3091bb2eb3d37b13ff.JPG
    [71] => 711f1a40732b20af24c398e59ab1424c.JPG
    [72] => 730f53625d7dcf1039dcdbc55a4d45db.JPG
    [73] => 76d0283314413dcb7fda2e3536819d3b.JPG
    [74] => 77d74dbb0ac844c58b6205be30714086.JPG
    [75] => 7b113ae538903f09f53e960ab35ff7eb.JPG
    [76] => 7b751e7b87b373698a3327332590b0fd.JPG
    [77] => 7f9d10d206b1380d59b5ec27b298614f.JPG
    [78] => 7f9e87e3f3529d61ccc8225c3195b8ea.JPG
    [79] => 811b1da20baf0b2091b69661fbe5e365.JPG
    [80] => 815d53677e82952c8a16665366c29ada.JPG
    [81] => 83777b4d592aedfb13c2af7f8ddfef3e.JPG
    [82] => 83e16a115c41b0df2dd3cd856d8512ab.JPG
    [83] => 855db7a987c513a3ce87cdc08136b2b8.JPG
    [84] => 87e9e7d0f0d7c825318aa2f9bfef429f.JPG
    [85] => 8bb8c5a1609de63cdb02336d05e5ebf3.JPG
    [86] => 8c730c247351581cc4a7f60c6ac34e74.JPG
    [87] => 8c8ebc03bd69233c9ec0bad4423a8828.JPG
    [88] => 8d94860d5b4e2d35b7759fb6063e8cc7.JPG
    [89] => 922cbe9965024100f74d692555815185.JPG
    [90] => 943459eb6234abb60960ad89abe42298.JPG
    [91] => 94cc381009fc6e8032d448132e7bc733.JPG
    [92] => 95e335956a4d7d792a070a4b19fce5fb.JPG
    [93] => 97745323890c0153581ebf9f767b934e.JPG
    [94] => 9822be06eb108538d6c02a2bd999ffd8.JPG
    [95] => 99e5d5b4be22d43b0830e9afff5cac3e.JPG
    [96] => 9dadeda97d123651804163ba1674c0ac.JPG
    [97] => 9e33420d210d28f1d4336a987e47f575.JPG
    [98] => 9f4bfd6c9a6b61b93d16eae0ccde0434.JPG
    [99] => a0780acf52eb42aba7d31a422f35030d.JPG
    [100] => a416abdd5f921f2433133e21d89e4f3c.JPG
    [101] => a431f2c37ebbdff1bdc73dbeddf1a272.JPG
    [102] => a4b75398f50d20d14b52cd7635f29a08.JPG
    [103] => a5be89a35e16145196a71890eb0218af.JPG
    [104] => a5ee7af3587819537d3f3ec57b67c360.JPG
    [105] => a8027741c5cd502d0f53c1709935c7f7.JPG
    [106] => ab36bc6515119f851100f39e79fbee18.JPG
    [107] => ad6ac0d82bbf2209c6e1931145efb682.JPG
    [108] => ad9e2e10cb9417ee8412ddae3544b213.JPG
    [109] => aeecacf5f891a89b17cfbfd3845ec7e1.JPG
    [110] => b1e00af98c6eee5dc80923948f77c31b.JPG
    [111] => b1fcce3c5b6ab08fcc53705531a64ecb.JPG
    [112] => b3845fe870c7f8be34765b6bd7d13fd9.JPG
    [113] => b54eb5995e31d4a589ddcc7fce5c12dd.JPG
    [114] => b6f49bf954b375eff77c0cd183bf35d7.JPG
    [115] => b7356b5afd6d70a77c50792d2304e322.JPG
    [116] => b813dc92733e083bf8ed3b676d8def9a.JPG
    [117] => b8a855d0689e6afd8014954cf751a0c8.JPG
    [118] => bbc62c3066dd3efb892ae92990131b89.JPG
    [119] => bc4ec2c6b65abcf0e6b52300fd568220.JPG
    [120] => be56e271479e6ace57bfcb57deaa2e82.JPG
    [121] => bf3dfddb558ec510ce4ba2da85a90bf3.JPG
    [122] => c1f9e5b5f5675aba30aade2128b515d9.JPG
    [123] => c377019b9f30482c9ad452c7dbab3a2e.JPG
    [124] => c5939a684154ef1cf69cf25b92b0cda4.JPG
    [125] => c9cc2edb540b718f520e4fa791f75c33.JPG
    [126] => c9e1a150b22c30eb5551077f19ca9ec7.JPG
    [127] => ccc83f1193898c8aa6404e8e6d2d2a8f.JPG
    [128] => cf0842bc141cef0d02aecc8bbc7407a6.JPG
    [129] => cf29cda2add9468fc21b92a27c410ed2.JPG
    [130] => d0017660a0362377d9d013d238df959a.JPG
    [131] => d05164a3a8a0a5a52632a1de97e77e98.JPG
    [132] => d06355b583d48d0992a8ea743bb95dd5.JPG
    [133] => d16dd48802d6d7adf4c8478b36461d3f.JPG
    [134] => d1e06a1cf68d2fb13010f73fb794dc6c.JPG
    [135] => d3dad31c9f8ef9b494888b5a013b8b44.JPG
    [136] => d3ffa80c4ae59b367fc6671cc75436ad.JPG
    [137] => d6dc0ab55bc079ba8482fb9fb8305b8a.JPG
    [138] => d719fa62db973dc2ecac75b8fa4cd547.JPG
    [139] => d8d63d9183913317d4f64effdce2b258.JPG
    [140] => dacf3cfa8262a939138f93c3ec0c0890.JPG
    [141] => dc41f62c33908866cfb0407374a740c4.JPG
    [142] => dda8956c6414440c5249aa599ce8e8d3.JPG
    [143] => de9d597e9af6996be36ff03410c007a8.JPG
    [144] => dff4f6e7f35459a566926c51db764c83.JPG
    [145] => e0150bdbeef20a5b71fa673293fabc3c.JPG
    [146] => e083a556033fb4f7a7b7b746d547864f.JPG
    [147] => e76652ec5a1038cf7d63456e6f3def4e.JPG
    [148] => e7f45031e08a320fe8d8a0227e363465.JPG
    [149] => eac5dbe33d57b1030bc5829bf7485545.JPG
    [150] => ecee0b7945c919716f935029d06e2a0b.JPG
    [151] => edbf4a7a1c0d32e069f2b5b0557caa9f.JPG
    [152] => eefcb69be6a9b0a340605b89e5a4f249.JPG
    [153] => f0c24d879cc0d25ec1aec161e9decc6d.JPG
    [154] => f0cd77e0f5d434e1e98b4e970c2a4e1a.JPG
    [155] => f2497dc12c61c8d3fa6d726a775a5a59.JPG
    [156] => f52efac281c67e302839df51b90231e8.JPG
    [157] => f73a9e956c3812900154a43dcf859e2e.JPG
    [158] => f7dd2f406e8929f488a901b29d72ba38.JPG
    [159] => fa26aba80d7cba267a9b306a54266cd4.JPG
    [160] => fe41e475fa39d4ab61a7cc6df37abb77.JPG
) 
Como usar array_diff para ver as figuras da maior que não existe na menor?

Compartilhar este post


Link para o post
Compartilhar em outros sites

Consegui fazer a primeira Array ficar assim:

 

Agora preciso usar a funçao


Array
(
    [0] => Array
        (
            [0] => b813dc92733e083bf8ed3b676d8def9a.JPG
            [1] => 0bb769196b966a479b306682598962db.JPG
            [2] => b7356b5afd6d70a77c50792d2304e322.JPG
            [3] => c1f9e5b5f5675aba30aade2128b515d9.JPG
            [4] => 6c833a8a61a8dc829683df49adfae65b.JPG
            [5] => 424a8e0242b46bd723a3a1a7d245143f.JPG
            [6] => f52efac281c67e302839df51b90231e8.JPG
            [7] => 9f4bfd6c9a6b61b93d16eae0ccde0434.JPG
            [8] => 62d6a89ca80dc2d8371db5b351e7c537.JPG
            [9] => bc4ec2c6b65abcf0e6b52300fd568220.JPG
        )

    [1] => Array
        (
            [0] => 922cbe9965024100f74d692555815185.JPG
            [1] => 46f55d4fbf6631a28704329486ab231d.JPG
            [2] => 2d530452ad9ed25d3de640e51706368f.JPG
            [3] => 0645a0f8569992f112e7176c9c5f00bf.JPG
            [4] => 730f53625d7dcf1039dcdbc55a4d45db.JPG
            [5] => bf3dfddb558ec510ce4ba2da85a90bf3.JPG
            [6] => b8a855d0689e6afd8014954cf751a0c8.JPG
            [7] => 01a3b6edf6ef1a9d7f075dbdafcb46d5.JPG
            [8] => 1b8abc0f9d025d7d9839d6360805a7d8.JPG
            [9] => dda8956c6414440c5249aa599ce8e8d3.JPG
        )

    [2] => Array
        (
            [0] => 6f6c6a8883eba477e593309d27d5869e.JPG
            [1] => b1e00af98c6eee5dc80923948f77c31b.JPG
            [2] => 
            [3] => 
            [4] => 
            [5] => 
            [6] => 
            [7] => 
            [8] => 
            [9] => 
        )

    [3] => Array
        (
            [0] => 54da631618a2c06779c042fa7e869298.JPG
            [1] => 1998e1fa94d1bcfbcc510e9235408d92.JPG
            [2] => 4edda823ec38c38c85cc7699152047d3.JPG
            [3] => d8d63d9183913317d4f64effdce2b258.JPG
            [4] => 351c3c03da61cca31b136b21d78c15c5.JPG
            [5] => 1cccc26be7e8270e29dd3e30f6cc8ed5.JPG
            [6] => 032fe1637da844c27011b7ec18b3f1e5.JPG
            [7] => 1d1b6bda0b93e414d9d3884f2352c98a.JPG
            [8] => 9822be06eb108538d6c02a2bd999ffd8.JPG
            [9] => 9dadeda97d123651804163ba1674c0ac.JPG
        )

    [4] => Array
        (
            [0] => b1fcce3c5b6ab08fcc53705531a64ecb.JPG
            [1] => 83777b4d592aedfb13c2af7f8ddfef3e.JPG
            [2] => 40bc639264ab98f2883697f29b02cc25.JPG
            [3] => ccc83f1193898c8aa6404e8e6d2d2a8f.JPG
            [4] => 8c8ebc03bd69233c9ec0bad4423a8828.JPG
            [5] => 
            [6] => 
            [7] => 
            [8] => 
            [9] => 
        )

    [5] => Array
        (
            [0] => 87e9e7d0f0d7c825318aa2f9bfef429f.JPG
            [1] => c9cc2edb540b718f520e4fa791f75c33.JPG
            [2] => dacf3cfa8262a939138f93c3ec0c0890.JPG
            [3] => 97745323890c0153581ebf9f767b934e.JPG
            [4] => 4b86a19a7c5b5802f55ed3d6e5487dea.JPG
            [5] => 4460ed16255089dd570c44c8900a1740.JPG
            [6] => 4261948cbcafa448ecc6304a308de405.JPG
            [7] => b54eb5995e31d4a589ddcc7fce5c12dd.JPG
            [8] => 6990dde9d86199a7704d9a3dbb21478e.JPG
            [9] => 83e16a115c41b0df2dd3cd856d8512ab.JPG
        )

    [6] => Array
        (
            [0] => 356e80715e8afea7fb29735760df9c26.JPG
            [1] => 8d94860d5b4e2d35b7759fb6063e8cc7.JPG
            [2] => 8bb8c5a1609de63cdb02336d05e5ebf3.JPG
            [3] => 7f9d10d206b1380d59b5ec27b298614f.JPG
            [4] => a5be89a35e16145196a71890eb0218af.JPG
            [5] => 6497e3e9462d24a9f67cb590d1d1ad15.JPG
            [6] => ad6ac0d82bbf2209c6e1931145efb682.JPG
            [7] => d1e06a1cf68d2fb13010f73fb794dc6c.JPG
            [8] => 4e80672b7f64d634bc850034ef8a76ab.JPG
            [9] => a0780acf52eb42aba7d31a422f35030d.JPG
        )

    [7] => Array
        (
            [0] => 38a30d48e560d12008b2cbd41d330525.JPG
            [1] => 811b1da20baf0b2091b69661fbe5e365.JPG
            [2] => a416abdd5f921f2433133e21d89e4f3c.JPG
            [3] => 815d53677e82952c8a16665366c29ada.JPG
            [4] => 0e840a2d8c1cec7a50225c6c1ccd3b6d.JPG
            [5] => c9e1a150b22c30eb5551077f19ca9ec7.JPG
            [6] => 0e5764ba367440dd2ce3f80373cbeaf1.JPG
            [7] => 855db7a987c513a3ce87cdc08136b2b8.JPG
            [8] => 5247d5e90e6258eb43f8ffc48237ca0d.JPG
            [9] => 
        )

    [8] => Array
        (
            [0] => 2abc37e7eec9f18fc4110214db7d0782.JPG
            [1] => 5e6437167928842d8f057634cec187da.JPG
            [2] => 76d0283314413dcb7fda2e3536819d3b.JPG
            [3] => de9d597e9af6996be36ff03410c007a8.JPG
            [4] => ad9e2e10cb9417ee8412ddae3544b213.JPG
            [5] => be56e271479e6ace57bfcb57deaa2e82.JPG
            [6] => 
            [7] => 
            [8] => 
            [9] => 
        )

    [9] => Array
        (
            [0] => a5ee7af3587819537d3f3ec57b67c360.JPG
            [1] => 58ed96533f0260a5cbdece2b452c8ace.JPG
            [2] => 30ce6023b854e2d9bfc3bce3b4a8450d.JPG
            [3] => 711f1a40732b20af24c398e59ab1424c.JPG
            [4] => f0c24d879cc0d25ec1aec161e9decc6d.JPG
            [5] => 
            [6] => 
            [7] => 
            [8] => 
            [9] => 
        )

    [10] => Array
        (
            [0] => a431f2c37ebbdff1bdc73dbeddf1a272.JPG
            [1] => 1891ced06048c08c5821f6f4d1271e8d.JPG
            [2] => 8c730c247351581cc4a7f60c6ac34e74.JPG
            [3] => 3b343e566ed497ca83a0e3ce0b3dba4c.JPG
            [4] => b3845fe870c7f8be34765b6bd7d13fd9.JPG
            [5] => 5a6e50cfec38613b425d4c5bbc38de93.JPG
            [6] => cf29cda2add9468fc21b92a27c410ed2.JPG
            [7] => 
            [8] => 
            [9] => 
        )

    [11] => Array
        (
            [0] => 007dcab84666a33e27908d8031f0c2eb.JPG
            [1] => a8027741c5cd502d0f53c1709935c7f7.JPG
            [2] => 14c5ca92b26682121feb8327eeb2181e.JPG
            [3] => 16fe71ee2ece654cb6fc1e9344395fa3.JPG
            [4] => d3ffa80c4ae59b367fc6671cc75436ad.JPG
            [5] => f7dd2f406e8929f488a901b29d72ba38.JPG
            [6] => f2497dc12c61c8d3fa6d726a775a5a59.JPG
            [7] => d16dd48802d6d7adf4c8478b36461d3f.JPG
            [8] => e083a556033fb4f7a7b7b746d547864f.JPG
            [9] => f73a9e956c3812900154a43dcf859e2e.JPG
        )

    [12] => Array
        (
            [0] => 0f72cecf3d1b485544eef9964458cded.JPG
            [1] => 2f1e5010518f49492acb7fc46fe6538a.JPG
            [2] => 63817385fd809e3fd51157367815a146.JPG
            [3] => e0150bdbeef20a5b71fa673293fabc3c.JPG
            [4] => 2ef98cb09a17411eec1fda7e5a247c38.JPG
            [5] => fe41e475fa39d4ab61a7cc6df37abb77.JPG
            [6] => 2331a215016cb84b426e7a8c378070f6.JPG
            [7] => 943459eb6234abb60960ad89abe42298.JPG
            [8] => 1a9a99a8e6bc125f68d8238f2cfb2ce0.JPG
            [9] => 200ff90afcb6c276beab6c7e32e4417d.JPG
        )

    [13] => Array
        (
            [0] => 0a1f350779f05dd6aabe69c6464425c9.JPG
            [1] => 1c76b10f2d2bc5f8c88d4689e8551bf2.JPG
            [2] => ecee0b7945c919716f935029d06e2a0b.JPG
            [3] => 6d2dc07b3ded08984b61ac895bc0a6ca.JPG
            [4] => dc41f62c33908866cfb0407374a740c4.JPG
            [5] => d05164a3a8a0a5a52632a1de97e77e98.JPG
            [6] => c5939a684154ef1cf69cf25b92b0cda4.JPG
            [7] => 35a5b08ec0837feb66b35e605f2ce209.JPG
            [8] => 19ffdb216d56164966a67ea0957621b2.JPG
            [9] => bbc62c3066dd3efb892ae92990131b89.JPG
        )

    [14] => Array
        (
            [0] => 2257769ca057ea83f8198d14b434e1b5.JPG
            [1] => 5530fbe884b04f9b3b9826b1f5febd36.JPG
            [2] => 7080341a7d9d3a3091bb2eb3d37b13ff.JPG
            [3] => 073fea87b2742f95e65d676997d944af.JPG
            [4] => 
            [5] => 
            [6] => 
            [7] => 
            [8] => 
            [9] => 
        )

    [15] => Array
        (
            [0] => d6dc0ab55bc079ba8482fb9fb8305b8a.JPG
            [1] => 
            [2] => 
            [3] => 
            [4] => 
            [5] => 
            [6] => 
            [7] => 
            [8] => 
            [9] => 
        )

)
E A OUTRA ESTA RETORNANDO ASSIM:


Array
(
    [0] => 007dcab84666a33e27908d8031f0c2eb.JPG
    [1] => 01a3b6edf6ef1a9d7f075dbdafcb46d5.JPG
    [2] => 01b173dfb6a5fe2364552b732ff538e9.JPG
    [3] => 032fe1637da844c27011b7ec18b3f1e5.JPG
    [4] => 03c8304b29a483d2490e039a356227df.JPG
    [5] => 04b4e9973f4bea00e159f216e794dbf6.JPG
    [6] => 0611ac57418ee227b8dca345f2670f6e.JPG
    [7] => 0645a0f8569992f112e7176c9c5f00bf.JPG
    [8] => 073fea87b2742f95e65d676997d944af.JPG
    [9] => 0a1f350779f05dd6aabe69c6464425c9.JPG
    [10] => 0bb769196b966a479b306682598962db.JPG
    [11] => 0c071d2b66dfc3b9f38ac3253fdbfcb8.JPG
    [12] => 0e5764ba367440dd2ce3f80373cbeaf1.JPG
    [13] => 0e840a2d8c1cec7a50225c6c1ccd3b6d.JPG
    [14] => 0f72cecf3d1b485544eef9964458cded.JPG
    [15] => 14afc903a7112dab1a0cc7839125b58f.JPG
    [16] => 14c5ca92b26682121feb8327eeb2181e.JPG
    [17] => 16fe71ee2ece654cb6fc1e9344395fa3.JPG
    [18] => 1891ced06048c08c5821f6f4d1271e8d.JPG
    [19] => 1998e1fa94d1bcfbcc510e9235408d92.JPG
    [20] => 19ffdb216d56164966a67ea0957621b2.JPG
    [21] => 1a9a99a8e6bc125f68d8238f2cfb2ce0.JPG
    [22] => 1b8abc0f9d025d7d9839d6360805a7d8.JPG
    [23] => 1c76b10f2d2bc5f8c88d4689e8551bf2.JPG
    [24] => 1cccc26be7e8270e29dd3e30f6cc8ed5.JPG
    [25] => 1d1b6bda0b93e414d9d3884f2352c98a.JPG
    [26] => 200ff90afcb6c276beab6c7e32e4417d.JPG
    [27] => 2257769ca057ea83f8198d14b434e1b5.JPG
    [28] => 2331a215016cb84b426e7a8c378070f6.JPG
    [29] => 2abc37e7eec9f18fc4110214db7d0782.JPG
    [30] => 2d530452ad9ed25d3de640e51706368f.JPG
    [31] => 2ef98cb09a17411eec1fda7e5a247c38.JPG
    [32] => 2f1e5010518f49492acb7fc46fe6538a.JPG
    [33] => 300cbc94c061e7cac391ce18e4bb2d28.JPG
    [34] => 30ce6023b854e2d9bfc3bce3b4a8450d.JPG
    [35] => 33414e7da806ac1dde8e4a5ebc79db1a.JPG
    [36] => 3410d1ac639595be7dff9241b8f4ff47.JPG
    [37] => 345fc952af8f4f3c471e766c1c31bae2.JPG
    [38] => 351c3c03da61cca31b136b21d78c15c5.JPG
    [39] => 356e80715e8afea7fb29735760df9c26.JPG
    [40] => 35a5b08ec0837feb66b35e605f2ce209.JPG
    [41] => 38a30d48e560d12008b2cbd41d330525.JPG
    [42] => 3b343e566ed497ca83a0e3ce0b3dba4c.JPG
    [43] => 3b76e7930236f1f6400d326549c28c3f.JPG
    [44] => 40bc639264ab98f2883697f29b02cc25.JPG
    [45] => 40d23f9b1fe4c3597f46d218b24ccde2.JPG
    [46] => 422d227412376b01ed02a3ad6a08252d.JPG
    [47] => 424a8e0242b46bd723a3a1a7d245143f.JPG
    [48] => 4261948cbcafa448ecc6304a308de405.JPG
    [49] => 4460ed16255089dd570c44c8900a1740.JPG
    [50] => 4503bd094d59e53de3ce39dbb4362dd4.JPG
    [51] => 45be13cefc69da9eeaa78a3ff00d397a.JPG
    [52] => 46f55d4fbf6631a28704329486ab231d.JPG
    [53] => 4b86a19a7c5b5802f55ed3d6e5487dea.JPG
    [54] => 4e80672b7f64d634bc850034ef8a76ab.JPG
    [55] => 4edda823ec38c38c85cc7699152047d3.JPG
    [56] => 51b7c0470958b45f7b3b04aeeac9e3a1.JPG
    [57] => 5247d5e90e6258eb43f8ffc48237ca0d.JPG
    [58] => 54da631618a2c06779c042fa7e869298.JPG
    [59] => 5530fbe884b04f9b3b9826b1f5febd36.JPG
    [60] => 58ed96533f0260a5cbdece2b452c8ace.JPG
    [61] => 5a6e50cfec38613b425d4c5bbc38de93.JPG
    [62] => 5e6437167928842d8f057634cec187da.JPG
    [63] => 62d6a89ca80dc2d8371db5b351e7c537.JPG
    [64] => 63817385fd809e3fd51157367815a146.JPG
    [65] => 6497e3e9462d24a9f67cb590d1d1ad15.JPG
    [66] => 6990dde9d86199a7704d9a3dbb21478e.JPG
    [67] => 6c833a8a61a8dc829683df49adfae65b.JPG
    [68] => 6d2dc07b3ded08984b61ac895bc0a6ca.JPG
    [69] => 6f6c6a8883eba477e593309d27d5869e.JPG
    [70] => 7080341a7d9d3a3091bb2eb3d37b13ff.JPG
    [71] => 711f1a40732b20af24c398e59ab1424c.JPG
    [72] => 730f53625d7dcf1039dcdbc55a4d45db.JPG
    [73] => 76d0283314413dcb7fda2e3536819d3b.JPG
    [74] => 77d74dbb0ac844c58b6205be30714086.JPG
    [75] => 7b113ae538903f09f53e960ab35ff7eb.JPG
    [76] => 7b751e7b87b373698a3327332590b0fd.JPG
    [77] => 7f9d10d206b1380d59b5ec27b298614f.JPG
    [78] => 7f9e87e3f3529d61ccc8225c3195b8ea.JPG
    [79] => 811b1da20baf0b2091b69661fbe5e365.JPG
    [80] => 815d53677e82952c8a16665366c29ada.JPG
    [81] => 83777b4d592aedfb13c2af7f8ddfef3e.JPG
    [82] => 83e16a115c41b0df2dd3cd856d8512ab.JPG
    [83] => 855db7a987c513a3ce87cdc08136b2b8.JPG
    [84] => 87e9e7d0f0d7c825318aa2f9bfef429f.JPG
    [85] => 8bb8c5a1609de63cdb02336d05e5ebf3.JPG
    [86] => 8c730c247351581cc4a7f60c6ac34e74.JPG
    [87] => 8c8ebc03bd69233c9ec0bad4423a8828.JPG
    [88] => 8d94860d5b4e2d35b7759fb6063e8cc7.JPG
    [89] => 922cbe9965024100f74d692555815185.JPG
    [90] => 943459eb6234abb60960ad89abe42298.JPG
    [91] => 94cc381009fc6e8032d448132e7bc733.JPG
    [92] => 95e335956a4d7d792a070a4b19fce5fb.JPG
    [93] => 97745323890c0153581ebf9f767b934e.JPG
    [94] => 9822be06eb108538d6c02a2bd999ffd8.JPG
    [95] => 99e5d5b4be22d43b0830e9afff5cac3e.JPG
    [96] => 9dadeda97d123651804163ba1674c0ac.JPG
    [97] => 9e33420d210d28f1d4336a987e47f575.JPG
    [98] => 9f4bfd6c9a6b61b93d16eae0ccde0434.JPG
    [99] => a0780acf52eb42aba7d31a422f35030d.JPG
    [100] => a416abdd5f921f2433133e21d89e4f3c.JPG
    [101] => a431f2c37ebbdff1bdc73dbeddf1a272.JPG
    [102] => a4b75398f50d20d14b52cd7635f29a08.JPG
    [103] => a5be89a35e16145196a71890eb0218af.JPG
    [104] => a5ee7af3587819537d3f3ec57b67c360.JPG
    [105] => a8027741c5cd502d0f53c1709935c7f7.JPG
    [106] => ab36bc6515119f851100f39e79fbee18.JPG
    [107] => ad6ac0d82bbf2209c6e1931145efb682.JPG
    [108] => ad9e2e10cb9417ee8412ddae3544b213.JPG
    [109] => aeecacf5f891a89b17cfbfd3845ec7e1.JPG
    [110] => b1e00af98c6eee5dc80923948f77c31b.JPG
    [111] => b1fcce3c5b6ab08fcc53705531a64ecb.JPG
    [112] => b3845fe870c7f8be34765b6bd7d13fd9.JPG
    [113] => b54eb5995e31d4a589ddcc7fce5c12dd.JPG
    [114] => b6f49bf954b375eff77c0cd183bf35d7.JPG
    [115] => b7356b5afd6d70a77c50792d2304e322.JPG
    [116] => b813dc92733e083bf8ed3b676d8def9a.JPG
    [117] => b8a855d0689e6afd8014954cf751a0c8.JPG
    [118] => bbc62c3066dd3efb892ae92990131b89.JPG
    [119] => bc4ec2c6b65abcf0e6b52300fd568220.JPG
    [120] => be56e271479e6ace57bfcb57deaa2e82.JPG
    [121] => bf3dfddb558ec510ce4ba2da85a90bf3.JPG
    [122] => c1f9e5b5f5675aba30aade2128b515d9.JPG
    [123] => c377019b9f30482c9ad452c7dbab3a2e.JPG
    [124] => c5939a684154ef1cf69cf25b92b0cda4.JPG
    [125] => c9cc2edb540b718f520e4fa791f75c33.JPG
    [126] => c9e1a150b22c30eb5551077f19ca9ec7.JPG
    [127] => ccc83f1193898c8aa6404e8e6d2d2a8f.JPG
    [128] => cf0842bc141cef0d02aecc8bbc7407a6.JPG
    [129] => cf29cda2add9468fc21b92a27c410ed2.JPG
    [130] => d0017660a0362377d9d013d238df959a.JPG
    [131] => d05164a3a8a0a5a52632a1de97e77e98.JPG
    [132] => d06355b583d48d0992a8ea743bb95dd5.JPG
    [133] => d16dd48802d6d7adf4c8478b36461d3f.JPG
    [134] => d1e06a1cf68d2fb13010f73fb794dc6c.JPG
    [135] => d3dad31c9f8ef9b494888b5a013b8b44.JPG
    [136] => d3ffa80c4ae59b367fc6671cc75436ad.JPG
    [137] => d6dc0ab55bc079ba8482fb9fb8305b8a.JPG
    [138] => d719fa62db973dc2ecac75b8fa4cd547.JPG
    [139] => d8d63d9183913317d4f64effdce2b258.JPG
    [140] => dacf3cfa8262a939138f93c3ec0c0890.JPG
    [141] => dc41f62c33908866cfb0407374a740c4.JPG
    [142] => dda8956c6414440c5249aa599ce8e8d3.JPG
    [143] => de9d597e9af6996be36ff03410c007a8.JPG
    [144] => dff4f6e7f35459a566926c51db764c83.JPG
    [145] => e0150bdbeef20a5b71fa673293fabc3c.JPG
    [146] => e083a556033fb4f7a7b7b746d547864f.JPG
    [147] => e76652ec5a1038cf7d63456e6f3def4e.JPG
    [148] => e7f45031e08a320fe8d8a0227e363465.JPG
    [149] => eac5dbe33d57b1030bc5829bf7485545.JPG
    [150] => ecee0b7945c919716f935029d06e2a0b.JPG
    [151] => edbf4a7a1c0d32e069f2b5b0557caa9f.JPG
    [152] => eefcb69be6a9b0a340605b89e5a4f249.JPG
    [153] => f0c24d879cc0d25ec1aec161e9decc6d.JPG
    [154] => f0cd77e0f5d434e1e98b4e970c2a4e1a.JPG
    [155] => f2497dc12c61c8d3fa6d726a775a5a59.JPG
    [156] => f52efac281c67e302839df51b90231e8.JPG
    [157] => f73a9e956c3812900154a43dcf859e2e.JPG
    [158] => f7dd2f406e8929f488a901b29d72ba38.JPG
    [159] => fa26aba80d7cba267a9b306a54266cd4.JPG
    [160] => fe41e475fa39d4ab61a7cc6df37abb77.JPG
) 
Como usar array_diff para ver as figuras da maior que não existe na menor?

Compartilhar este post


Link para o post
Compartilhar em outros sites

Sabe aquelas plaquinhas motivacionais: "U're doing it wrong!" ? Então...

 

<?php

# Parte do banco de dados
$conn = mysql_connect('localhost','root','') or die(mysql_error());
$db = mysql_select_db('imasters') or die(mysql_error());

$sql = "SELECT `foto`, `foto2`, `foto3`, `foto4`, `foto5`, `foto6`, `foto7`, `foto8`, `foto9`, `foto10` FROM `ImoveisCadastroVenda`";
$rs = mysql_query($sql, $conn) or die(mysql_error());

$fotosDb = array();
while(false !== ($row = mysql_fetch_row($rs))) $fotosDb = array_merge($fotosDb, $row);

# Fim da parte do banco de dados, início da parte de diretórios

chdir('imagens');
$fotosDiretorio = glob('*.{jpg,gif,png}', GLOB_BRACE);

foreach(array_diff($fotosDiretorio, $fotosDb) as $apagar) unlink($apagar);

Compartilhar este post


Link para o post
Compartilhar em outros sites

Mas olha só:

 

Me responde uma coisa:

No codigo abaixo:

		  for ($i=0;$i<sizeof($NomesFotos2);$i++)
		  {
			  $fotografia[]=explode(";",$NomesFotos2[$i]);
		  }

		  for ($i=0;$i<mysql_num_rows($sql);$i++){
			 $foto[]="$"."fotografia[$i]";
		  }
		  $fotos= implode(',',$foto);

		  print $fotos;
		  $dir = "imagens/upload/venda/miniaturas/";
		  $NomeTodasFotos1= varre($dir);		
		  $result = array_diff($NomeTodasFotos1,$fotos);
		  print_r($result)."<p><p><p>";
Expecificadamente nessa parte

for ($i=0;$i<mysql_num_rows($sql);$i++){
			 $foto[]="$"."fotografia[$i]";
		  }
		  $fotos= implode(',',$foto);

		  print $fotos;
		  $dir = "imagens/upload/venda/miniaturas/";
		  $NomeTodasFotos1= varre($dir);		
		  $result = array_diff($NomeTodasFotos1,$fotos);
		  print_r($result)."<p><p><p>";
a variavel $fotos me retorna seguinte:

$fotografia[0],$fotografia[1],$fotografia[2],$fotografia[3],$fotografia[4],$fotografia[5],$fotografia[6],$fotografia[7],$fotografia[8],$fotografia[9],$fotografia[10],$fotografia[11],$fotografia[12],$fotografia[13],$fotografia[14],$fotografia[15] 
porem, se eu jogar essa variavel como esta no codigo na array_diff, não funciona. Porem, se eu jogar seu conteudo la ai funciona.

Tipo:

		  $result = array_diff($NomeTodasFotos1,$fotografia[0],$fotografia[1],$fotografia[2],$fotografia[3],$fotografia[4],$fotografia[5],$fotografia[6],$fotografia[7],$fotografia[8],$fotografia[9],$fotografia[10],$fotografia[11],$fotografia[12],$fotografia[13],$fotografia[14],$fotografia[15] 
);
		  print_r($result)."<p><p><p>";
Porque?

Compartilhar este post


Link para o post
Compartilhar em outros sites

Não entendo porque você está complicando tudo heheheh, fazendo explode's, implode's, for's. O Evandro já mostrou como fazer, de uma forma bem simples e que funciona.

 

Veja, o processo é gerar duas listas (arrays), uma contendo o nome das imagens salvas no banco de dados, e outra lista com os arquivos salvos no servidor. Feito isso, utilizando apenas uma função de array do PHP, você encontra as imagens que estão no servidor e não estão no banco de dados. Do resto é só mandar um unlink() nelas e acabou! Não precisa de fazer implode para depois fazer explode nem nada, é simples.

 

Aproveitando, vale a leitura: http://pt.wikipedia.org/wiki/Keep_It_Simple

Compartilhar este post


Link para o post
Compartilhar em outros sites

Ok

 

Entendi mais ou menos.

Mas, e no caso de eu ter dois diretorios com as mesmas fotos (miniaturas e normais) como fazer se chdir só há uma vez no código?

 

<?php 
header('Content-Type: text/html; charset=utf-8');
include ("global/funcoes_php/var.php");
include("global/funcoes_php/conexao.php"); 
$MySQL = new TMySQL();
$MySQL->connect($host, $db, $user, $pass);

$sql = "SELECT `foto`, `foto2`, `foto3`, `foto4`, `foto5`, `foto6`, `foto7`, `foto8`, `foto9`, `foto10` FROM `ImoveisCadastroVenda`";
$rs = mysql_query($sql) or die(mysql_error());

$fotosDb = array();
while(false !== ($row = mysql_fetch_row($rs))) 
$fotosDb = array_merge($fotosDb, $row);

# Fim da parte do banco de dados, início da parte de diretórios

//chdir('imagens/upload/venda/miniaturas/');
chdir('imagens/upload/venda/normais/');
$fotosDiretorio = glob('*.{JPG,JPEG,GIF,PNG,jpg,jpeg,gif,png}', GLOB_BRACE);

foreach(array_diff($fotosDiretorio, $fotosDb) as $apagar) unlink($apagar);

?>

Compartilhar este post


Link para o post
Compartilhar em outros sites
chdir('imagens/upload/venda/normais/');
$fotosDiretorio = glob('*.{JPG,JPEG,GIF,PNG,jpg,jpeg,gif,png}', GLOB_BRACE);

foreach(array_diff($fotosDiretorio, $fotosDb) as $apagar) unlink($apagar);

chdir('imagens/upload/venda/miniaturas/');
$fotosDiretorio = glob('*.{JPG,JPEG,GIF,PNG,jpg,jpeg,gif,png}', GLOB_BRACE);

foreach(array_diff($fotosDiretorio, $fotosDb) as $apagar) unlink($apagar);

Compartilhar este post


Link para o post
Compartilhar em outros sites

Ok.

Entendido todo o processo mas, só para a questão de aprendizado mesmo.

 

E, se no diretorio, tiver por exemplo, arquivos .doc e não tiver como voce ter controle disso, como seria?

Pergunto pois ai não haverá como usar a função glob.

chdir('imagens/upload/venda/normais/');
$fotosDiretorio = glob('*.{JPG,JPEG,GIF,PNG,jpg,jpeg,gif,png}', GLOB_BRACE);
Ou vai?

Nesse casoi deveria ser do jeito que eu estava fazendo mesmo né?

<?php 
header('Content-Type: text/html; charset=utf-8');
include ("global/funcoes_php/var.php");
include("global/funcoes_php/conexao.php"); 
$MySQL = new TMySQL();
$MySQL->connect($host, $db, $user, $pass);
?>

<?php
function varre ($dir) {
// Abre um diretorio conhecido, e faz a leitura de seu conteudo
if (is_dir($dir)) {
    if ($dh = opendir($dir)) {
        while (($file = readdir($dh)) !== false) {
           $NomesFotos[] = $file;
        }
        closedir($dh);
    }
}
$NomeTodasFotos = implode(';',$NomesFotos);
$NomeTodasFotos = substr($NomeTodasFotos, 5);
$NomeTodasFotos = explode(';',$NomeTodasFotos);
return $NomeTodasFotos;
} 

   $sql=mysql_query("
	    select 
			ImoveisCadastroVenda.Foto, 
			ImoveisCadastroVenda.Foto2, 
			ImoveisCadastroVenda.Foto3, 
			ImoveisCadastroVenda.Foto4, 
			ImoveisCadastroVenda.Foto5, 
			ImoveisCadastroVenda.Foto6, 
			ImoveisCadastroVenda.Foto7, 
			ImoveisCadastroVenda.Foto8,
			ImoveisCadastroVenda.Foto9, 
			ImoveisCadastroVenda.Foto10 
		from 
		   ImoveisCadastroVenda 
		        ") or die("iiiiiiiii");
		
		while (list($Foto1,$Foto2,$Foto3,$Foto4,$Foto5,$Foto6,$Foto7,$Foto8,$Foto9,$Foto10) = mysql_fetch_row($sql)){
			$NomesFotos2[] = $Foto1.";".$Foto2.";".$Foto3.";".$Foto4.";".$Foto5.";".$Foto6.";".$Foto7.";".$Foto8.";".$Foto9.";".$Foto10;
		  }

		  for ($i=0;$i<sizeof($NomesFotos2);$i++)
		  {
			  $fotografia[]=explode(";",$NomesFotos2[$i]);
		  }

		  print_r($fotografia);
		  $dir = "imagens/upload/venda/miniaturas/";
		  $NomeTodasFotos1= varre($dir);		
		  $result = array_diff($NomeTodasFotos1,$fotografia);//aqui preciso colocar cada uma das $fotografias[$i] acho!!!!!!!
		    print_r($result)."<p><p><p>";
  
		  foreach ($result as $arr) {
			 // unlink($dir.$arr);
		  }
		     
?> 
Ou não? Se não, como?

 

Até aqui meu muito obrigado a todos que colaboraram neste post.

 

Fica o aguardo pela ultima resposta

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.