combineren van mulitple 2 dimentional arrays

Overzicht Reageren

Sponsored by: Vacatures door Monsterboard

PHP Developers gezocht die van complexe online vra

Vacature Omschrijving Een grote klant is opzoek naar enthousiaste PHP developers (junior/medior/senior). De organisatie waar jij komt te werken ontwikkelt en bouwt succesvolle oplossingen voor complexe online vraagstukken zoals performance, usability en conversion. Daarnaast zorgen zij voor externe systemen ingericht voor productbeheer, point-of-sales en voorraadbeheer koppelt de organisatie probleemloos aan op eigen Magento gebaseerde webshops. Het is een informele organisatie waar de communicatielijnen kort zijn. Functieomschrijving Met drupal 8 of ShopWare realiseert de organisatie prachtige frond-ends op dynamische data uit allerlei systemen. Je houdt je in deze organisatie bezig met het ontwerpen, ontwikkelen en beheren van functionaliteiten van de applicaties

Bekijk vacature »

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

22/07/2019 12:44:15
 
- 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.