combineren van mulitple 2 dimentional arrays

Overzicht Reageren

Sponsored by: Vacatures door Monsterboard

Daniel van Seggelen

Daniel van Seggelen

14/09/2017 16:24:43
Quote Anchor link
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?php
$arr
= array("dir_subcat" => "".$_POST['dir_subcat']."",
"by_name" => "".$_POST['by_name']."",
"geo_distance" => "".$_POST['geo_distance']."",
"zip" => "".$_POST['zip']."",
"geo_location" => "".$_POST['geo_location']."",
"latitude" => "51.514792",
"longitude" => "-0.235745",
"title" => "Demo 1",
'name' => 'Demo 1',
"email" => "info@braakwater.nl",
"phone_numer" => "345345345",
"group" => "doctor",
"icon" => "".HTML_ROOT."images/02.png",
"html" => array("content" => "<div class=\"tg-map-marker\"><figure class=\"tg-docimg\"><a class=\"userlink\" href=\"".HTML_ROOT."en_US/docdirecttor/professional/\"><img src=\"".HTML_ROOT."images/user270x270.jpg\" alt=\"User\"><span class=\"tg-show\"><em class=\"icon-add\"></em></span></a><a data-view_type=\"v1\" class=\"tg-like add-to-fav\" data-wl_id=\"340\" href=\"javascript:;\"><i class=\"fa fa-heart\"></i></a>\t\t\t\t\t\t<span class=\"user-verified\">\r\n\t\t\t\t\t\t\t<svg id=\"Icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"74.875\" height=\"21\" viewBox=\"0 0 74.875 21\"> <defs>\r\n\t\t\t\t\t\t\t<style>.cls-1{fill:#10a64a}.cls-2{font-size:16px;text-anchor:middle;font-family:FontAwesome;text-transform:uppercase}.cls-2,.cls-3{fill:#fff}.cls-3{font-size:14.437px;font-family:Montserrat}</style></defs> \r\n\t\t\t\t\t\t\t<rect id=\"BG\" class=\"cls-1\" width=\"74.875\" height=\"21\" rx=\"3\" ry=\"3\"/> <text id=\"_\" data-name=\"uf132\" class=\"cls-2\" transform=\"translate(14.829 14.99) scale(0.737 0.762)\">&#xF132;</text> \r\n\t\t\t\t\t\t\t<text id=\"Verified\" class=\"cls-3\" transform=\"translate(22.787 15.191) scale(0.737 0.762)\">Verified</text> </svg>\r\n\t\t\r\n\t\t\t\t\t\t</span><div class=\"feature-rating user-star-rating\"><span class=\"tg-stars star-rating\"><span style=\"width:50%\"></span></span><em>2.0<sub>/2</sub></em></div>\r\n\t\t\t\t\t</figure><div class=\"tg-mapmarker-content\"><div class=\"tg-heading-border tg-small\"><h3><a class=\"userlink\" href=\"".HTML_ROOT."en_US/docdirecttor/professional\">Demo 1</a></h3></div><ul class=\"tg-info\"><li> <i class=\"fa fa-envelope\"></i> <em><a href=\"mailto:demo@themographics.com?Subject=hello\" target=\"_top\">demo@themographics.com</a></em> </li><li> <i class=\"fa fa-phone\"></i> <em><a href=\"javascript:;\">64 235 856843</a></em> </li></ul></div></div>") );

$arr= array("dir_subcat" => "".$_POST['dir_subcat']."",
"by_name" => "".$_POST['by_name']."",
"geo_distance" => "".$_POST['geo_distance']."",
"zip" => "".$_POST['zip']."",
"geo_location" => "".$_POST['geo_location']."",
"latitude" => "53.514792",
"longitude" => "-0.635745",
"title" => "Demo 2",
'name' => 'Demo 2',
"email" => "info@braakwater.nl",
"phone_numer" => "345345345",
"group" => "doctor",
"icon" => "".HTML_ROOT."images/01.png",
"html" => array("content" => "<div class=\"tg-map-marker\"><figure class=\"tg-docimg\"><a class=\"userlink\" href=\"".HTML_ROOT."en_US/docdirecttor/professional/\"><img src=\"".HTML_ROOT."images/user270x270.jpg\" alt=\"User\"><span class=\"tg-show\"><em class=\"icon-add\"></em></span></a><a data-view_type=\"v1\" class=\"tg-like add-to-fav\" data-wl_id=\"340\" href=\"javascript:;\"><i class=\"fa fa-heart\"></i></a>\t\t\t\t\t\t<span class=\"user-verified\">\r\n\t\t\t\t\t\t\t<svg id=\"Icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"74.875\" height=\"21\" viewBox=\"0 0 74.875 21\"> <defs>\r\n\t\t\t\t\t\t\t<style>.cls-1{fill:#10a64a}.cls-2{font-size:16px;text-anchor:middle;font-family:FontAwesome;text-transform:uppercase}.cls-2,.cls-3{fill:#fff}.cls-3{font-size:14.437px;font-family:Montserrat}</style></defs> \r\n\t\t\t\t\t\t\t<rect id=\"BG\" class=\"cls-1\" width=\"74.875\" height=\"21\" rx=\"3\" ry=\"3\"/> <text id=\"_\" data-name=\"uf132\" class=\"cls-2\" transform=\"translate(14.829 14.99) scale(0.737 0.762)\">&#xF132;</text> \r\n\t\t\t\t\t\t\t<text id=\"Verified\" class=\"cls-3\" transform=\"translate(22.787 15.191) scale(0.737 0.762)\">Verified</text> </svg>\r\n\t\t\r\n\t\t\t\t\t\t</span><div class=\"feature-rating user-star-rating\"><span class=\"tg-stars star-rating\"><span style=\"width:50%\"></span></span><em>2.0<sub>/2</sub></em></div>\r\n\t\t\t\t\t</figure><div class=\"tg-mapmarker-content\"><div class=\"tg-heading-border tg-small\"><h3><a class=\"userlink\" href=\"".HTML_ROOT."en_US/docdirecttor/professional\">Demo 2</a></h3></div><ul class=\"tg-info\"><li> <i class=\"fa fa-envelope\"></i> <em><a href=\"mailto:demo@themographics.com?Subject=hello\" target=\"_top\">demo@themographics.com</a></em> </li><li> <i class=\"fa fa-phone\"></i> <em><a href=\"javascript:;\">64 235 856843</a></em> </li></ul></div></div>") );
?>


Ik stuur die zooi terug met:

echo json_encode($arr, JSON_UNESCAPED_UNICODE);



Hij pakt alleen de laatste, maar ik moet het uit een loop halen,
Hoe gaat dit?
Gewijzigd op 14/09/2017 16:40:12 door - Ariën -
 
PHP hulp

PHP hulp

17/12/2018 21:44:21
 
- Ariën -
Beheerder

- Ariën -

14/09/2017 16:28:29
Quote Anchor link
Heb je wat meer code?
 
- SanThe -

- SanThe -

14/09/2017 16:38:06
Quote Anchor link
Daniel van Seggelen op 14/09/2017 16:24:43:
Hij pakt alleen de laatste, maar ik moet het uit een loop halen


Uiteraard want je overschrijft het op regel 16.

$arr = array();
En dan vullen met:
$arr[] = ..........;
$arr[] = ..........;
Gewijzigd op 14/09/2017 16:40:49 door - SanThe -
 
- Ariën -
Beheerder

- Ariën -

14/09/2017 16:39:52
Quote Anchor link
Als je het tussen <?php-tags zet, dan zie je ook de syntax-kleurtjes ;-)

Anyway, done. :-)
Gewijzigd op 14/09/2017 16:40:41 door - Ariën -
 
Daniel van Seggelen

Daniel van Seggelen

14/09/2017 17:09:43
Quote Anchor link
Quote:
$arr = array();
En dan vullen met:
$arr[] = ..........;
$arr[] = ..........;


Had ik ook geprobeert, maar ik krijg een foutmelding, dat hij de content niet kan lezen. Dit heb ik ook geprobeert:

Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
$marks
=array("status" => "found", "user_list" =>
array("dir_subcat" => "".$_GET['dir_subcat']."",
"geo_distance" => "".$_GET['geo_distance']."",
"geo_location" => "".$_GET['geo_location']."",
"latitude" => "51.514792",
"longitude" => "-0.235745",
"title" => "Demo 1",
'name' => 'Demo 1',
"email" => "info@braakwater.nl",
"phone_numer" => "345345345",
"group" => "doctor",
"icon" => "".HTML_ROOT."images/02.png",
"html" => array("content" => "<div class=\"tg-map-marker\"><figure class=\"tg-docimg\"><a class=\"userlink\" href=\"".HTML_ROOT."en_US/docdirecttor/professional/\"><img src=\"".HTML_ROOT."images/user270x270.jpg\" alt=\"User\"><span class=\"tg-show\"><em class=\"icon-add\"></em></span></a><a data-view_type=\"v1\" class=\"tg-like add-to-fav\" data-wl_id=\"340\" href=\"javascript:;\"><i class=\"fa fa-heart\"></i></a>\t\t\t\t\t\t<span class=\"user-verified\">\r\n\t\t\t\t\t\t\t<svg id=\"Icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"74.875\" height=\"21\" viewBox=\"0 0 74.875 21\"> <defs>\r\n\t\t\t\t\t\t\t<style>.cls-1{fill:#10a64a}.cls-2{font-size:16px;text-anchor:middle;font-family:FontAwesome;text-transform:uppercase}.cls-2,.cls-3{fill:#fff}.cls-3{font-size:14.437px;font-family:Montserrat}</style></defs> \r\n\t\t\t\t\t\t\t<rect id=\"BG\" class=\"cls-1\" width=\"74.875\" height=\"21\" rx=\"3\" ry=\"3\"/> <text id=\"_\" data-name=\"uf132\" class=\"cls-2\" transform=\"translate(14.829 14.99) scale(0.737 0.762)\">&#xF132;</text> \r\n\t\t\t\t\t\t\t<text id=\"Verified\" class=\"cls-3\" transform=\"translate(22.787 15.191) scale(0.737 0.762)\">Verified</text> </svg>\r\n\t\t\r\n\t\t\t\t\t\t</span><div class=\"feature-rating user-star-rating\"><span class=\"tg-stars star-rating\"><span style=\"width:50%\"></span></span><em>2.0<sub>/2</sub></em></div>\r\n\t\t\t\t\t</figure><div class=\"tg-mapmarker-content\"><div class=\"tg-heading-border tg-small\"><h3><a class=\"userlink\" href=\"".HTML_ROOT."en_US/docdirecttor/professional\">Demo 1</a></h3></div><ul class=\"tg-info\"><li> <i class=\"fa fa-envelope\"></i> <em><a href=\"mailto:demo@themographics.com?Subject=hello\" target=\"_top\">demo@themographics.com</a></em> </li><li> <i class=\"fa fa-phone\"></i> <em><a href=\"javascript:;\">64 235 856843</a></em> </li></ul></div></div>") )
,

array("dir_subcat" => "".$_GET['dir_subcat']."",
"geo_distance" => "".$_GET['geo_distance']."",
"geo_location" => "".$_GET['geo_location']."",
"latitude" => "51.514792",
"longitude" => "-0.235745",
"title" => "Demo 2",
'name' => 'Demo 2',
"email" => "info@braakwater.nl",
"phone_numer" => "345345345",
"group" => "doctor",
"icon" => "".HTML_ROOT."images/02.png",
"html" => array("content" => "<div class=\"tg-map-marker\"><figure class=\"tg-docimg\"><a class=\"userlink\" href=\"".HTML_ROOT."en_US/docdirecttor/professional/\"><img src=\"".HTML_ROOT."images/user270x270.jpg\" alt=\"User\"><span class=\"tg-show\"><em class=\"icon-add\"></em></span></a><a data-view_type=\"v1\" class=\"tg-like add-to-fav\" data-wl_id=\"340\" href=\"javascript:;\"><i class=\"fa fa-heart\"></i></a>\t\t\t\t\t\t<span class=\"user-verified\">\r\n\t\t\t\t\t\t\t<svg id=\"Icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"74.875\" height=\"21\" viewBox=\"0 0 74.875 21\"> <defs>\r\n\t\t\t\t\t\t\t<style>.cls-1{fill:#10a64a}.cls-2{font-size:16px;text-anchor:middle;font-family:FontAwesome;text-transform:uppercase}.cls-2,.cls-3{fill:#fff}.cls-3{font-size:14.437px;font-family:Montserrat}</style></defs> \r\n\t\t\t\t\t\t\t<rect id=\"BG\" class=\"cls-1\" width=\"74.875\" height=\"21\" rx=\"3\" ry=\"3\"/> <text id=\"_\" data-name=\"uf132\" class=\"cls-2\" transform=\"translate(14.829 14.99) scale(0.737 0.762)\">&#xF132;</text> \r\n\t\t\t\t\t\t\t<text id=\"Verified\" class=\"cls-3\" transform=\"translate(22.787 15.191) scale(0.737 0.762)\">Verified</text> </svg>\r\n\t\t\r\n\t\t\t\t\t\t</span><div class=\"feature-rating user-star-rating\"><span class=\"tg-stars star-rating\"><span style=\"width:50%\"></span></span><em>2.0<sub>/2</sub></em></div>\r\n\t\t\t\t\t</figure><div class=\"tg-mapmarker-content\"><div class=\"tg-heading-border tg-small\"><h3><a class=\"userlink\" href=\"".HTML_ROOT."en_US/docdirecttor/professional\">Demo 1</a></h3></div><ul class=\"tg-info\"><li> <i class=\"fa fa-envelope\"></i> <em><a href=\"mailto:demo@themographics.com?Subject=hello\" target=\"_top\">demo@themographics.com</a></em> </li><li> <i class=\"fa fa-phone\"></i> <em><a href=\"javascript:;\">64 235 856843</a></em> </li></ul></div></div>") )
,

array("dir_subcat" => "".$_GET['dir_subcat']."",
"geo_distance" => "".$_GET['geo_distance']."",
"geo_location" => "".$_GET['geo_location']."",
"latitude" => "51.514792",
"longitude" => "-0.235745",
"title" => "Demo 3",
'name' => 'Demo 3',
"email" => "info@braakwater.nl",
"phone_numer" => "345345345",
"group" => "doctor",
"icon" => "".HTML_ROOT."images/02.png",
"html" => array("content" => "<div class=\"tg-map-marker\"><figure class=\"tg-docimg\"><a class=\"userlink\" href=\"".HTML_ROOT."en_US/docdirecttor/professional/\"><img src=\"".HTML_ROOT."images/user270x270.jpg\" alt=\"User\"><span class=\"tg-show\"><em class=\"icon-add\"></em></span></a><a data-view_type=\"v1\" class=\"tg-like add-to-fav\" data-wl_id=\"340\" href=\"javascript:;\"><i class=\"fa fa-heart\"></i></a>\t\t\t\t\t\t<span class=\"user-verified\">\r\n\t\t\t\t\t\t\t<svg id=\"Icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"74.875\" height=\"21\" viewBox=\"0 0 74.875 21\"> <defs>\r\n\t\t\t\t\t\t\t<style>.cls-1{fill:#10a64a}.cls-2{font-size:16px;text-anchor:middle;font-family:FontAwesome;text-transform:uppercase}.cls-2,.cls-3{fill:#fff}.cls-3{font-size:14.437px;font-family:Montserrat}</style></defs> \r\n\t\t\t\t\t\t\t<rect id=\"BG\" class=\"cls-1\" width=\"74.875\" height=\"21\" rx=\"3\" ry=\"3\"/> <text id=\"_\" data-name=\"uf132\" class=\"cls-2\" transform=\"translate(14.829 14.99) scale(0.737 0.762)\">&#xF132;</text> \r\n\t\t\t\t\t\t\t<text id=\"Verified\" class=\"cls-3\" transform=\"translate(22.787 15.191) scale(0.737 0.762)\">Verified</text> </svg>\r\n\t\t\r\n\t\t\t\t\t\t</span><div class=\"feature-rating user-star-rating\"><span class=\"tg-stars star-rating\"><span style=\"width:50%\"></span></span><em>2.0<sub>/2</sub></em></div>\r\n\t\t\t\t\t</figure><div class=\"tg-mapmarker-content\"><div class=\"tg-heading-border tg-small\"><h3><a class=\"userlink\" href=\"".HTML_ROOT."en_US/docdirecttor/professional\">Demo 1</a></h3></div><ul class=\"tg-info\"><li> <i class=\"fa fa-envelope\"></i> <em><a href=\"mailto:demo@themographics.com?Subject=hello\" target=\"_top\">demo@themographics.com</a></em> </li><li> <i class=\"fa fa-phone\"></i> <em><a href=\"javascript:;\">64 235 856843</a></em> </li></ul></div></div>") )
);

?>


lukt niet.

Uiteindelijk, moet ik dit terug krijgen:

Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
docdirect_init_map_script({"status": "found",
"users_list": [
<?php
//$arr = array("region" => "valore","price" => "valore2");



//echo json_encode($arr, JSON_PRETTY_PRINT);

?>

//,
{
    "latitude": "51.514792",
    "longitude": "-0.235745",
    "title": "Demo Professional",
    "name": "Demo Professional",
    "email": "demo@themographics.com",
    "phone_number": "64 235 856843",
    "address": "",
    "group": "doctor",
    "icon": "\/\/localhost\/docdirect\/wp-content\/themes\/docdirect\/images\/02.png",
    "html": {
        "content": "<div class=\"tg-map-marker\"><figure class=\"tg-docimg\"><a class=\"userlink\" href=\"<?=HTML_ROOT_JSON?>\/en_US\/docdirecttor\/professional\/\"><img src=\"<?=HTML_ROOT_JSON?>\/wp-content\/themes\/docdirect\/images\/img-17-270x270.jpg\" alt=\"User\"><span class=\"tg-show\"><em class=\"icon-add\"><\/em><\/span><\/a><a data-view_type=\"v1\" class=\"tg-like add-to-fav\" data-wl_id=\"340\" href=\"javascript:;\"><i class=\"fa fa-heart\"><\/i><\/a>\t\t\t\t\t\t<span class=\"user-verified\">\r\n\t\t\t\t\t\t\t<svg id=\"Icon\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"74.875\" height=\"21\" viewBox=\"0 0 74.875 21\"> <defs>\r\n\t\t\t\t\t\t\t<style>.cls-1{fill:#10a64a}.cls-2{font-size:16px;text-anchor:middle;font-family:FontAwesome;text-transform:uppercase}.cls-2,.cls-3{fill:#fff}.cls-3{font-size:14.437px;font-family:Montserrat}<\/style><\/defs> \r\n\t\t\t\t\t\t\t<rect id=\"BG\" class=\"cls-1\" width=\"74.875\" height=\"21\" rx=\"3\" ry=\"3\"\/> <text id=\"_\" data-name=\"\uf132\" class=\"cls-2\" transform=\"translate(14.829 14.99) scale(0.737 0.762)\">\uf132<\/text> \r\n\t\t\t\t\t\t\t<text id=\"Verified\" class=\"cls-3\" transform=\"translate(22.787 15.191) scale(0.737 0.762)\">Verified<\/text> <\/svg>\r\n\t\t\r\n\t\t\t\t\t\t<\/span>\r\n\t\t\t\t\t<\/figure><div class=\"tg-mapmarker-content\"><div class=\"tg-heading-border tg-small\"><h3><a class=\"userlink\" href=\"<?=HTML_ROOT_JSON?>\/en_US\/docdirecttor\/professional\/\">Demo Professional<\/a><\/h3><\/div><ul class=\"tg-info\"><li> <i class=\"fa fa-envelope\"><\/i> <em><a href=\"mailto:demo@themographics.com?Subject=hello\" target=\"_top\">demo@themographics.com<\/a><\/em> <\/li><li> <i class=\"fa fa-phone\"><\/i> <em><a href=\"javascript:;\">64 235 856843<\/a><\/em> <\/li><\/ul><\/div><\/div>"
    }
}
}]
});
});


Als ik namelijk dat zo statisch in een variabele plak werkt het wel netjes.
 



Overzicht Reageren

 
 

Om de gebruiksvriendelijkheid van onze website en diensten te optimaliseren maken wij gebruik van cookies. Deze cookies gebruiken wij voor functionaliteiten, analytische gegevens en marketing doeleinden. U vindt meer informatie in onze privacy statement.