How do I apply a function to this array

0

I have this array that returns the id of the images but with a wordpress function I need to apply them to each of the id that returns the array and this function will be responsible for converting them into url, each one .

This returns the array with var_dump() .

array(2) {\n  [0]=>\n  int(10741)\n  [1]=>\n  int(10742)\n}
    
asked by Santiago D'Antuoni 24.11.2016 в 16:49
source

2 answers

2

@Muriano has already given you an answer, to get all the ids of the images, you must store them in an array.

<?php
    foreach($arrayImagenes as $idImagen) {
        $urlImagen[] = funcion_wordpress($idImagen);
    }
    
answered by 24.11.2016 / 17:24
source
0
<?php
    foreach($arrayImagenes as $idImagen) {

          $urlImagen = funcion_wordpress($idImagen);

    }

From that code you already decide if you want to save each image url in a variable or in an array. foreach is a structure that works with elements of type "iterable" and allows you to store in a variable (as $ idImage) each of these "iterations" to work with them in the way you want, for example, pass it as argument to a function.

    
answered by 24.11.2016 в 16:51