Articles Tagged 'usort ()'

Sort an array of arrays in PHP

vista in WordPress: ordinare una serie di post per un campo qualsiasi può essere utilizzata facilmente anche per ordinare array di array . PHP function usort ( ) seen in Wordpress: order a series of posts for any field can be used to easily sort arrays of arrays. For example if we have:

1
2
3
4
5
6
7
8
9
array ( $ Args = array (
'nome' => 'mike' , 'anno' => 2001 ) , array ('name' => 'Mike', 'year' => 2001),
'nome' => 'frank' , 'anno' => 2010 ) , array ('name' => 'Frank', 'year' => 2010),
...
);

$args , function ( $a , $b ) { usort ($ args, function ($ a, $ b) {
$a [ 'anno' ] > $b [ 'anno' ] ) ; return ($ a ['year']> $ b ['year']);
});

Continued ...

Retrieve the images loaded in a Post

When writing a Post in WordPress you can upload images to the same time writing the article. These images, which are part of the media library, are associated with that particular post. The peculiarity of this behavior lies in the ability to extract these images no matter if they were physically placed inside the post.

Continued ...

Wordpress: order a series of posts for any field

o un array di oggetti. The technique that I describe here is useful in many situations where, for example, we have an array of array or array of objects. , senza aver accesso alla select originale (sul database) che ha generato l'elenco (array) stesso: In WordPress you may want to manipulate a list of posts, in the standard format array of stdClass Object without having access to select the original (the database) that generated the list (array) itself:

Continued ...


Stop SOPA