Welcome to the Cookbook

loading...

8.5.6 normalize

array Set::normalize ($list, $assoc = true, $sep = ',', $trim = true)

Normalise une chaîne ou une liste de tableau.

$a = array('Arbre', 'CompteurDeCache','Telechargement' => array(
			'repertoire' => 'produits',
			'champs' => array('image_1_id', 'image_2_id', 'image_3_id', 'image_4_id', 'image_5_id')
));
$b =  array('Cachable' => array('actif' => false),
		'Limite',
		'Liaison',
		'Validateur',
		'Transactionnel');
$resultat = Set::normalize($a);
/* $resultat ressemble maintenant à :
	Array
	(
	    [Arbre] => 
	    [CompteurDeCache] => 
	    [Telechargement] => Array
	        (
	            [repertoire] => produits
	            [champs] => Array
	                (
	                    [0] => image_1_id
	                    [1] => image_2_id
	                    [2] => image_3_id
	                    [3] => image_4_id
	                    [4] => image_5_id
	                )
	        )
	)
*/
$resultat = Set::normalize($b);
/* $resultat ressemble maintenant à :
	Array
	(
	    [Cachable] => Array
	        (
	            [actif] => 
	        )

	    [Limite] => 
	    [Liaison] => 
	    [Validateur] => 
	    [Transactionnel] => 
	)
*/
$resultat = Set::merge($a, $b); // Maintenant mixons les deux et normalisons
/* $resultat ressemble maintenant à :
	Array
	(
	    [0] => Arbre
	    [1] => CompteurDeCache
	    [Telechargement] => Array
	        (
	            [repertoire] => produits
	            [champs] => Array
	                (
	                    [0] => image_1_id
	                    [1] => image_2_id
	                    [2] => image_3_id
	                    [3] => image_4_id
	                    [4] => image_5_id
	                )

	        )
	    [Cachable] => Array
	        (
	            [actif] => 
	        )
	    [2] => Limite
	    [3] => Liaison
	    [4] => Validateur
	    [5] => Transactionnel
	)
*/
$resultat = Set::normalize(Set::merge($a, $b));
/* $resultat ressemble maintenant à :
	Array
	(
	    [Arbre] => 
	    [CompteurDeCache] => 
	    [Telechargement] => Array
	        (
	            [repertoire] => products
	            [champs] => Array
	                (
	                    [0] => image_1_id
	                    [1] => image_2_id
	                    [2] => image_3_id
	                    [3] => image_4_id
	                    [4] => image_5_id
	                )

	        )
	    [Cachable] => Array
	        (
	            [actif] => 
	        )
	    [Limite] => 
	    [Liaison] => 
	    [Validateur] => 
	    [Transactionnel] => 
	)
*/
  1. $a = array('Arbre', 'CompteurDeCache','Telechargement' => array(
  2. 'repertoire' => 'produits',
  3. 'champs' => array('image_1_id', 'image_2_id', 'image_3_id', 'image_4_id', 'image_5_id')
  4. ));
  5. $b = array('Cachable' => array('actif' => false),
  6. 'Limite',
  7. 'Liaison',
  8. 'Validateur',
  9. 'Transactionnel');
  10. $resultat = Set::normalize($a);
  11. /* $resultat ressemble maintenant à :
  12. Array
  13. (
  14. [Arbre] =>
  15. [CompteurDeCache] =>
  16. [Telechargement] => Array
  17. (
  18. [repertoire] => produits
  19. [champs] => Array
  20. (
  21. [0] => image_1_id
  22. [1] => image_2_id
  23. [2] => image_3_id
  24. [3] => image_4_id
  25. [4] => image_5_id
  26. )
  27. )
  28. )
  29. */
  30. $resultat = Set::normalize($b);
  31. /* $resultat ressemble maintenant à :
  32. Array
  33. (
  34. [Cachable] => Array
  35. (
  36. [actif] =>
  37. )
  38. [Limite] =>
  39. [Liaison] =>
  40. [Validateur] =>
  41. [Transactionnel] =>
  42. )
  43. */
  44. $resultat = Set::merge($a, $b); // Maintenant mixons les deux et normalisons
  45. /* $resultat ressemble maintenant à :
  46. Array
  47. (
  48. [0] => Arbre
  49. [1] => CompteurDeCache
  50. [Telechargement] => Array
  51. (
  52. [repertoire] => produits
  53. [champs] => Array
  54. (
  55. [0] => image_1_id
  56. [1] => image_2_id
  57. [2] => image_3_id
  58. [3] => image_4_id
  59. [4] => image_5_id
  60. )
  61. )
  62. [Cachable] => Array
  63. (
  64. [actif] =>
  65. )
  66. [2] => Limite
  67. [3] => Liaison
  68. [4] => Validateur
  69. [5] => Transactionnel
  70. )
  71. */
  72. $resultat = Set::normalize(Set::merge($a, $b));
  73. /* $resultat ressemble maintenant à :
  74. Array
  75. (
  76. [Arbre] =>
  77. [CompteurDeCache] =>
  78. [Telechargement] => Array
  79. (
  80. [repertoire] => products
  81. [champs] => Array
  82. (
  83. [0] => image_1_id
  84. [1] => image_2_id
  85. [2] => image_3_id
  86. [3] => image_4_id
  87. [4] => image_5_id
  88. )
  89. )
  90. [Cachable] => Array
  91. (
  92. [actif] =>
  93. )
  94. [Limite] =>
  95. [Liaison] =>
  96. [Validateur] =>
  97. [Transactionnel] =>
  98. )
  99. */