Pick a particular field out of an inner array
before the traitement :
print_r ($value) =
Prise en chargeListe des d�p�tsSaisie parflashageSupervisionSupervision des fluxSuivi des flux informatiquesAdministrationContr�le des RADMContr�le des RPECSurveillanceJournalJournal de bordAudit des depots
the traitement
foreach ($toto as $data)
{
foreach($data as $key => $value)
{
$value = $value. ',';
$tab = explode(",", $value);
print_r($tab);
}
}
After the traitement :
print_r($tab) =
Array ( [0] => Prise en charge [1] => ) Array ( [0] => Liste des d�p�ts [1] => ) Array ( [0] => Saisie par flashage [1] => ) Array ( [0] => Supervision [1] => ) Array ( [0] => Supervision des flux [1] => ) Array ( [0] => Suivi des flux informatiques [1] => ) Array ( [0] => Administration [1] => ) Array ( [0] => Contr�le des RADM [1] => ) Array ( [0] => Contr�le des RPEC [1] => ) Array ( [0] => Surveillance [1] => ) Array ( [0] => Journal [1] => ) Array ( [0] => Journal de bord [1] => ) Array ( [0] => Audit des depots [1] => )
My question : Why he not give me the array like that :
Array
// (
// [0] => Prise en charge
// [1] => Liste des d�p�ts
// [2] => etc
// [3] => etc
// [4] => etc
// [5] => etc
// )
Here is a sample of the original $toto data:
var_dump($toto) = array(13) { [0]=> array(1) { ["name"]=> string(15) "Prise en charge" } [1]=> array(1) { ["name"]=> string(16) "Liste des dépôts" } [2]=> array(1) { ["name"]=> string(19) "Saisie par flashage" } [3]=> array(1) { ["name"]=> string(11) "Supervision" } [4]=> array(1) { ["name"]=> string(20) "Supervision des flux" } [5]=> array(1) { ["name"]=> string(28) "Suivi des flux informatiques" } [6]=> array(1) { ["name"]=> string(14) "Administration" } [7]=> array(1) { ["name"]=> string(17) "Contrôle des RADM" }
php version: less than 5.5
php arrays
add a comment |
before the traitement :
print_r ($value) =
Prise en chargeListe des d�p�tsSaisie parflashageSupervisionSupervision des fluxSuivi des flux informatiquesAdministrationContr�le des RADMContr�le des RPECSurveillanceJournalJournal de bordAudit des depots
the traitement
foreach ($toto as $data)
{
foreach($data as $key => $value)
{
$value = $value. ',';
$tab = explode(",", $value);
print_r($tab);
}
}
After the traitement :
print_r($tab) =
Array ( [0] => Prise en charge [1] => ) Array ( [0] => Liste des d�p�ts [1] => ) Array ( [0] => Saisie par flashage [1] => ) Array ( [0] => Supervision [1] => ) Array ( [0] => Supervision des flux [1] => ) Array ( [0] => Suivi des flux informatiques [1] => ) Array ( [0] => Administration [1] => ) Array ( [0] => Contr�le des RADM [1] => ) Array ( [0] => Contr�le des RPEC [1] => ) Array ( [0] => Surveillance [1] => ) Array ( [0] => Journal [1] => ) Array ( [0] => Journal de bord [1] => ) Array ( [0] => Audit des depots [1] => )
My question : Why he not give me the array like that :
Array
// (
// [0] => Prise en charge
// [1] => Liste des d�p�ts
// [2] => etc
// [3] => etc
// [4] => etc
// [5] => etc
// )
Here is a sample of the original $toto data:
var_dump($toto) = array(13) { [0]=> array(1) { ["name"]=> string(15) "Prise en charge" } [1]=> array(1) { ["name"]=> string(16) "Liste des dépôts" } [2]=> array(1) { ["name"]=> string(19) "Saisie par flashage" } [3]=> array(1) { ["name"]=> string(11) "Supervision" } [4]=> array(1) { ["name"]=> string(20) "Supervision des flux" } [5]=> array(1) { ["name"]=> string(28) "Suivi des flux informatiques" } [6]=> array(1) { ["name"]=> string(14) "Administration" } [7]=> array(1) { ["name"]=> string(17) "Contrôle des RADM" }
php version: less than 5.5
php arrays
2
because you exploded each individual section, not the whole thing. Wait until you've added commas to everything, and then explode the whole line
– ADyson
Nov 20 '18 at 14:43
I did not understand, i have to add the ',' in the $data ?
– Nico
Nov 20 '18 at 14:45
You added it to the $value. not the $data. and then you exploded the $value. So fine, add it to $value. But then don't do the explode until after the loop. Unless I misunderstood. What is the content of $toto? It's not 100% clear where you are starting from, exactly.
– ADyson
Nov 20 '18 at 14:45
var_dump($toto) = array(13) { [0]=> array(1) { ["name"]=> string(15) "Prise en charge" } [1]=> array(1) { ["name"]=> string(16) "Liste des dépôts" } [2]=> array(1) { ["name"]=> string(19) "Saisie par flashage" } [3]=> array(1) { ["name"]=> string(11) "Supervision" } [4]=> array(1) { ["name"]=> string(20) "Supervision des flux" } [5]=> array(1) { ["name"]=> string(28) "Suivi des flux informatiques" } [6]=> array(1) { ["name"]=> string(14) "Administration" } [7]=> array(1) { ["name"]=> string(17) "Contrôle des RADM" }
– Nico
Nov 20 '18 at 14:48
I retrieve my SQL query in my $toto and i want to isolate the text, that's why i used 2 foreach
– Nico
Nov 20 '18 at 14:50
add a comment |
before the traitement :
print_r ($value) =
Prise en chargeListe des d�p�tsSaisie parflashageSupervisionSupervision des fluxSuivi des flux informatiquesAdministrationContr�le des RADMContr�le des RPECSurveillanceJournalJournal de bordAudit des depots
the traitement
foreach ($toto as $data)
{
foreach($data as $key => $value)
{
$value = $value. ',';
$tab = explode(",", $value);
print_r($tab);
}
}
After the traitement :
print_r($tab) =
Array ( [0] => Prise en charge [1] => ) Array ( [0] => Liste des d�p�ts [1] => ) Array ( [0] => Saisie par flashage [1] => ) Array ( [0] => Supervision [1] => ) Array ( [0] => Supervision des flux [1] => ) Array ( [0] => Suivi des flux informatiques [1] => ) Array ( [0] => Administration [1] => ) Array ( [0] => Contr�le des RADM [1] => ) Array ( [0] => Contr�le des RPEC [1] => ) Array ( [0] => Surveillance [1] => ) Array ( [0] => Journal [1] => ) Array ( [0] => Journal de bord [1] => ) Array ( [0] => Audit des depots [1] => )
My question : Why he not give me the array like that :
Array
// (
// [0] => Prise en charge
// [1] => Liste des d�p�ts
// [2] => etc
// [3] => etc
// [4] => etc
// [5] => etc
// )
Here is a sample of the original $toto data:
var_dump($toto) = array(13) { [0]=> array(1) { ["name"]=> string(15) "Prise en charge" } [1]=> array(1) { ["name"]=> string(16) "Liste des dépôts" } [2]=> array(1) { ["name"]=> string(19) "Saisie par flashage" } [3]=> array(1) { ["name"]=> string(11) "Supervision" } [4]=> array(1) { ["name"]=> string(20) "Supervision des flux" } [5]=> array(1) { ["name"]=> string(28) "Suivi des flux informatiques" } [6]=> array(1) { ["name"]=> string(14) "Administration" } [7]=> array(1) { ["name"]=> string(17) "Contrôle des RADM" }
php version: less than 5.5
php arrays
before the traitement :
print_r ($value) =
Prise en chargeListe des d�p�tsSaisie parflashageSupervisionSupervision des fluxSuivi des flux informatiquesAdministrationContr�le des RADMContr�le des RPECSurveillanceJournalJournal de bordAudit des depots
the traitement
foreach ($toto as $data)
{
foreach($data as $key => $value)
{
$value = $value. ',';
$tab = explode(",", $value);
print_r($tab);
}
}
After the traitement :
print_r($tab) =
Array ( [0] => Prise en charge [1] => ) Array ( [0] => Liste des d�p�ts [1] => ) Array ( [0] => Saisie par flashage [1] => ) Array ( [0] => Supervision [1] => ) Array ( [0] => Supervision des flux [1] => ) Array ( [0] => Suivi des flux informatiques [1] => ) Array ( [0] => Administration [1] => ) Array ( [0] => Contr�le des RADM [1] => ) Array ( [0] => Contr�le des RPEC [1] => ) Array ( [0] => Surveillance [1] => ) Array ( [0] => Journal [1] => ) Array ( [0] => Journal de bord [1] => ) Array ( [0] => Audit des depots [1] => )
My question : Why he not give me the array like that :
Array
// (
// [0] => Prise en charge
// [1] => Liste des d�p�ts
// [2] => etc
// [3] => etc
// [4] => etc
// [5] => etc
// )
Here is a sample of the original $toto data:
var_dump($toto) = array(13) { [0]=> array(1) { ["name"]=> string(15) "Prise en charge" } [1]=> array(1) { ["name"]=> string(16) "Liste des dépôts" } [2]=> array(1) { ["name"]=> string(19) "Saisie par flashage" } [3]=> array(1) { ["name"]=> string(11) "Supervision" } [4]=> array(1) { ["name"]=> string(20) "Supervision des flux" } [5]=> array(1) { ["name"]=> string(28) "Suivi des flux informatiques" } [6]=> array(1) { ["name"]=> string(14) "Administration" } [7]=> array(1) { ["name"]=> string(17) "Contrôle des RADM" }
php version: less than 5.5
php arrays
php arrays
edited Dec 28 '18 at 18:53
Community♦
11
11
asked Nov 20 '18 at 14:40
NicoNico
919
919
2
because you exploded each individual section, not the whole thing. Wait until you've added commas to everything, and then explode the whole line
– ADyson
Nov 20 '18 at 14:43
I did not understand, i have to add the ',' in the $data ?
– Nico
Nov 20 '18 at 14:45
You added it to the $value. not the $data. and then you exploded the $value. So fine, add it to $value. But then don't do the explode until after the loop. Unless I misunderstood. What is the content of $toto? It's not 100% clear where you are starting from, exactly.
– ADyson
Nov 20 '18 at 14:45
var_dump($toto) = array(13) { [0]=> array(1) { ["name"]=> string(15) "Prise en charge" } [1]=> array(1) { ["name"]=> string(16) "Liste des dépôts" } [2]=> array(1) { ["name"]=> string(19) "Saisie par flashage" } [3]=> array(1) { ["name"]=> string(11) "Supervision" } [4]=> array(1) { ["name"]=> string(20) "Supervision des flux" } [5]=> array(1) { ["name"]=> string(28) "Suivi des flux informatiques" } [6]=> array(1) { ["name"]=> string(14) "Administration" } [7]=> array(1) { ["name"]=> string(17) "Contrôle des RADM" }
– Nico
Nov 20 '18 at 14:48
I retrieve my SQL query in my $toto and i want to isolate the text, that's why i used 2 foreach
– Nico
Nov 20 '18 at 14:50
add a comment |
2
because you exploded each individual section, not the whole thing. Wait until you've added commas to everything, and then explode the whole line
– ADyson
Nov 20 '18 at 14:43
I did not understand, i have to add the ',' in the $data ?
– Nico
Nov 20 '18 at 14:45
You added it to the $value. not the $data. and then you exploded the $value. So fine, add it to $value. But then don't do the explode until after the loop. Unless I misunderstood. What is the content of $toto? It's not 100% clear where you are starting from, exactly.
– ADyson
Nov 20 '18 at 14:45
var_dump($toto) = array(13) { [0]=> array(1) { ["name"]=> string(15) "Prise en charge" } [1]=> array(1) { ["name"]=> string(16) "Liste des dépôts" } [2]=> array(1) { ["name"]=> string(19) "Saisie par flashage" } [3]=> array(1) { ["name"]=> string(11) "Supervision" } [4]=> array(1) { ["name"]=> string(20) "Supervision des flux" } [5]=> array(1) { ["name"]=> string(28) "Suivi des flux informatiques" } [6]=> array(1) { ["name"]=> string(14) "Administration" } [7]=> array(1) { ["name"]=> string(17) "Contrôle des RADM" }
– Nico
Nov 20 '18 at 14:48
I retrieve my SQL query in my $toto and i want to isolate the text, that's why i used 2 foreach
– Nico
Nov 20 '18 at 14:50
2
2
because you exploded each individual section, not the whole thing. Wait until you've added commas to everything, and then explode the whole line
– ADyson
Nov 20 '18 at 14:43
because you exploded each individual section, not the whole thing. Wait until you've added commas to everything, and then explode the whole line
– ADyson
Nov 20 '18 at 14:43
I did not understand, i have to add the ',' in the $data ?
– Nico
Nov 20 '18 at 14:45
I did not understand, i have to add the ',' in the $data ?
– Nico
Nov 20 '18 at 14:45
You added it to the $value. not the $data. and then you exploded the $value. So fine, add it to $value. But then don't do the explode until after the loop. Unless I misunderstood. What is the content of $toto? It's not 100% clear where you are starting from, exactly.
– ADyson
Nov 20 '18 at 14:45
You added it to the $value. not the $data. and then you exploded the $value. So fine, add it to $value. But then don't do the explode until after the loop. Unless I misunderstood. What is the content of $toto? It's not 100% clear where you are starting from, exactly.
– ADyson
Nov 20 '18 at 14:45
var_dump($toto) = array(13) { [0]=> array(1) { ["name"]=> string(15) "Prise en charge" } [1]=> array(1) { ["name"]=> string(16) "Liste des dépôts" } [2]=> array(1) { ["name"]=> string(19) "Saisie par flashage" } [3]=> array(1) { ["name"]=> string(11) "Supervision" } [4]=> array(1) { ["name"]=> string(20) "Supervision des flux" } [5]=> array(1) { ["name"]=> string(28) "Suivi des flux informatiques" } [6]=> array(1) { ["name"]=> string(14) "Administration" } [7]=> array(1) { ["name"]=> string(17) "Contrôle des RADM" }
– Nico
Nov 20 '18 at 14:48
var_dump($toto) = array(13) { [0]=> array(1) { ["name"]=> string(15) "Prise en charge" } [1]=> array(1) { ["name"]=> string(16) "Liste des dépôts" } [2]=> array(1) { ["name"]=> string(19) "Saisie par flashage" } [3]=> array(1) { ["name"]=> string(11) "Supervision" } [4]=> array(1) { ["name"]=> string(20) "Supervision des flux" } [5]=> array(1) { ["name"]=> string(28) "Suivi des flux informatiques" } [6]=> array(1) { ["name"]=> string(14) "Administration" } [7]=> array(1) { ["name"]=> string(17) "Contrôle des RADM" }
– Nico
Nov 20 '18 at 14:48
I retrieve my SQL query in my $toto and i want to isolate the text, that's why i used 2 foreach
– Nico
Nov 20 '18 at 14:50
I retrieve my SQL query in my $toto and i want to isolate the text, that's why i used 2 foreach
– Nico
Nov 20 '18 at 14:50
add a comment |
1 Answer
1
active
oldest
votes
It seems you simply want to pick a particular field out of each inner array.
You can solve this in one line as follows, without messing about with loops, commas etc:
print_r(array_column($toto, 'name'));
This will output
Array
(
[0] => Prise en charge
[1] => Liste des dépôts
[2] => Saisie par flashage
[3] => Supervision
[4] => Supervision des flux
[5] => Suivi des flux informatiques
[6] => Administration
[7] => Contrôle des RADM
etc.
Demo: http://sandbox.onlinephpfunctions.com/code/09d7cde83b58b8c6a84be66f4fcc45d3f4fef6a8
Documentation: http://php.net/manual/en/function.array-column.php
Additional:
If you don't have the array_column function available, then it's still fairly simple to solve like this:
$output = array();
foreach ($toto as $data)
{
$output = $data["name"];
}
print_r($output);
the function array_column() is for php 5.5 ? because i've got a fatale error when i use it
– Nico
Nov 20 '18 at 15:28
yes, that's when it was introduced. Are you running an older version? If so you should consider upgrading urgently, as you are not receiving critical security patches and other updates. See php.net/supported-versions.php . P.S. In your question you didn't specify your PHP version, so I assumed (reasonably, I would say) that you had a recent version.
– ADyson
Nov 20 '18 at 15:30
I understand now, sorry I should have said it before. I can not upgrade for php 7 or 5.5, I do not have the right in my company: / I will change the title so sorry
– Nico
Nov 20 '18 at 15:35
Hm, you should warn your company they are endangering their security, and that of their data (or their clients' data, if that's what the application holds). Running an unsupported version is irresponsible, frankly. Upgrading is not that hard, in most cases, and certainly the impact can be tested. Even if it's not your responsibility, you should make them aware that you think it's a bad practice.
– ADyson
Nov 20 '18 at 15:40
Anyway, I added a simple alternative solution as an extra part of the answer.
– ADyson
Nov 20 '18 at 15:42
|
show 1 more comment
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53395446%2fpick-a-particular-field-out-of-an-inner-array%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
It seems you simply want to pick a particular field out of each inner array.
You can solve this in one line as follows, without messing about with loops, commas etc:
print_r(array_column($toto, 'name'));
This will output
Array
(
[0] => Prise en charge
[1] => Liste des dépôts
[2] => Saisie par flashage
[3] => Supervision
[4] => Supervision des flux
[5] => Suivi des flux informatiques
[6] => Administration
[7] => Contrôle des RADM
etc.
Demo: http://sandbox.onlinephpfunctions.com/code/09d7cde83b58b8c6a84be66f4fcc45d3f4fef6a8
Documentation: http://php.net/manual/en/function.array-column.php
Additional:
If you don't have the array_column function available, then it's still fairly simple to solve like this:
$output = array();
foreach ($toto as $data)
{
$output = $data["name"];
}
print_r($output);
the function array_column() is for php 5.5 ? because i've got a fatale error when i use it
– Nico
Nov 20 '18 at 15:28
yes, that's when it was introduced. Are you running an older version? If so you should consider upgrading urgently, as you are not receiving critical security patches and other updates. See php.net/supported-versions.php . P.S. In your question you didn't specify your PHP version, so I assumed (reasonably, I would say) that you had a recent version.
– ADyson
Nov 20 '18 at 15:30
I understand now, sorry I should have said it before. I can not upgrade for php 7 or 5.5, I do not have the right in my company: / I will change the title so sorry
– Nico
Nov 20 '18 at 15:35
Hm, you should warn your company they are endangering their security, and that of their data (or their clients' data, if that's what the application holds). Running an unsupported version is irresponsible, frankly. Upgrading is not that hard, in most cases, and certainly the impact can be tested. Even if it's not your responsibility, you should make them aware that you think it's a bad practice.
– ADyson
Nov 20 '18 at 15:40
Anyway, I added a simple alternative solution as an extra part of the answer.
– ADyson
Nov 20 '18 at 15:42
|
show 1 more comment
It seems you simply want to pick a particular field out of each inner array.
You can solve this in one line as follows, without messing about with loops, commas etc:
print_r(array_column($toto, 'name'));
This will output
Array
(
[0] => Prise en charge
[1] => Liste des dépôts
[2] => Saisie par flashage
[3] => Supervision
[4] => Supervision des flux
[5] => Suivi des flux informatiques
[6] => Administration
[7] => Contrôle des RADM
etc.
Demo: http://sandbox.onlinephpfunctions.com/code/09d7cde83b58b8c6a84be66f4fcc45d3f4fef6a8
Documentation: http://php.net/manual/en/function.array-column.php
Additional:
If you don't have the array_column function available, then it's still fairly simple to solve like this:
$output = array();
foreach ($toto as $data)
{
$output = $data["name"];
}
print_r($output);
the function array_column() is for php 5.5 ? because i've got a fatale error when i use it
– Nico
Nov 20 '18 at 15:28
yes, that's when it was introduced. Are you running an older version? If so you should consider upgrading urgently, as you are not receiving critical security patches and other updates. See php.net/supported-versions.php . P.S. In your question you didn't specify your PHP version, so I assumed (reasonably, I would say) that you had a recent version.
– ADyson
Nov 20 '18 at 15:30
I understand now, sorry I should have said it before. I can not upgrade for php 7 or 5.5, I do not have the right in my company: / I will change the title so sorry
– Nico
Nov 20 '18 at 15:35
Hm, you should warn your company they are endangering their security, and that of their data (or their clients' data, if that's what the application holds). Running an unsupported version is irresponsible, frankly. Upgrading is not that hard, in most cases, and certainly the impact can be tested. Even if it's not your responsibility, you should make them aware that you think it's a bad practice.
– ADyson
Nov 20 '18 at 15:40
Anyway, I added a simple alternative solution as an extra part of the answer.
– ADyson
Nov 20 '18 at 15:42
|
show 1 more comment
It seems you simply want to pick a particular field out of each inner array.
You can solve this in one line as follows, without messing about with loops, commas etc:
print_r(array_column($toto, 'name'));
This will output
Array
(
[0] => Prise en charge
[1] => Liste des dépôts
[2] => Saisie par flashage
[3] => Supervision
[4] => Supervision des flux
[5] => Suivi des flux informatiques
[6] => Administration
[7] => Contrôle des RADM
etc.
Demo: http://sandbox.onlinephpfunctions.com/code/09d7cde83b58b8c6a84be66f4fcc45d3f4fef6a8
Documentation: http://php.net/manual/en/function.array-column.php
Additional:
If you don't have the array_column function available, then it's still fairly simple to solve like this:
$output = array();
foreach ($toto as $data)
{
$output = $data["name"];
}
print_r($output);
It seems you simply want to pick a particular field out of each inner array.
You can solve this in one line as follows, without messing about with loops, commas etc:
print_r(array_column($toto, 'name'));
This will output
Array
(
[0] => Prise en charge
[1] => Liste des dépôts
[2] => Saisie par flashage
[3] => Supervision
[4] => Supervision des flux
[5] => Suivi des flux informatiques
[6] => Administration
[7] => Contrôle des RADM
etc.
Demo: http://sandbox.onlinephpfunctions.com/code/09d7cde83b58b8c6a84be66f4fcc45d3f4fef6a8
Documentation: http://php.net/manual/en/function.array-column.php
Additional:
If you don't have the array_column function available, then it's still fairly simple to solve like this:
$output = array();
foreach ($toto as $data)
{
$output = $data["name"];
}
print_r($output);
edited Nov 20 '18 at 15:42
answered Nov 20 '18 at 15:09
ADysonADyson
24.3k112545
24.3k112545
the function array_column() is for php 5.5 ? because i've got a fatale error when i use it
– Nico
Nov 20 '18 at 15:28
yes, that's when it was introduced. Are you running an older version? If so you should consider upgrading urgently, as you are not receiving critical security patches and other updates. See php.net/supported-versions.php . P.S. In your question you didn't specify your PHP version, so I assumed (reasonably, I would say) that you had a recent version.
– ADyson
Nov 20 '18 at 15:30
I understand now, sorry I should have said it before. I can not upgrade for php 7 or 5.5, I do not have the right in my company: / I will change the title so sorry
– Nico
Nov 20 '18 at 15:35
Hm, you should warn your company they are endangering their security, and that of their data (or their clients' data, if that's what the application holds). Running an unsupported version is irresponsible, frankly. Upgrading is not that hard, in most cases, and certainly the impact can be tested. Even if it's not your responsibility, you should make them aware that you think it's a bad practice.
– ADyson
Nov 20 '18 at 15:40
Anyway, I added a simple alternative solution as an extra part of the answer.
– ADyson
Nov 20 '18 at 15:42
|
show 1 more comment
the function array_column() is for php 5.5 ? because i've got a fatale error when i use it
– Nico
Nov 20 '18 at 15:28
yes, that's when it was introduced. Are you running an older version? If so you should consider upgrading urgently, as you are not receiving critical security patches and other updates. See php.net/supported-versions.php . P.S. In your question you didn't specify your PHP version, so I assumed (reasonably, I would say) that you had a recent version.
– ADyson
Nov 20 '18 at 15:30
I understand now, sorry I should have said it before. I can not upgrade for php 7 or 5.5, I do not have the right in my company: / I will change the title so sorry
– Nico
Nov 20 '18 at 15:35
Hm, you should warn your company they are endangering their security, and that of their data (or their clients' data, if that's what the application holds). Running an unsupported version is irresponsible, frankly. Upgrading is not that hard, in most cases, and certainly the impact can be tested. Even if it's not your responsibility, you should make them aware that you think it's a bad practice.
– ADyson
Nov 20 '18 at 15:40
Anyway, I added a simple alternative solution as an extra part of the answer.
– ADyson
Nov 20 '18 at 15:42
the function array_column() is for php 5.5 ? because i've got a fatale error when i use it
– Nico
Nov 20 '18 at 15:28
the function array_column() is for php 5.5 ? because i've got a fatale error when i use it
– Nico
Nov 20 '18 at 15:28
yes, that's when it was introduced. Are you running an older version? If so you should consider upgrading urgently, as you are not receiving critical security patches and other updates. See php.net/supported-versions.php . P.S. In your question you didn't specify your PHP version, so I assumed (reasonably, I would say) that you had a recent version.
– ADyson
Nov 20 '18 at 15:30
yes, that's when it was introduced. Are you running an older version? If so you should consider upgrading urgently, as you are not receiving critical security patches and other updates. See php.net/supported-versions.php . P.S. In your question you didn't specify your PHP version, so I assumed (reasonably, I would say) that you had a recent version.
– ADyson
Nov 20 '18 at 15:30
I understand now, sorry I should have said it before. I can not upgrade for php 7 or 5.5, I do not have the right in my company: / I will change the title so sorry
– Nico
Nov 20 '18 at 15:35
I understand now, sorry I should have said it before. I can not upgrade for php 7 or 5.5, I do not have the right in my company: / I will change the title so sorry
– Nico
Nov 20 '18 at 15:35
Hm, you should warn your company they are endangering their security, and that of their data (or their clients' data, if that's what the application holds). Running an unsupported version is irresponsible, frankly. Upgrading is not that hard, in most cases, and certainly the impact can be tested. Even if it's not your responsibility, you should make them aware that you think it's a bad practice.
– ADyson
Nov 20 '18 at 15:40
Hm, you should warn your company they are endangering their security, and that of their data (or their clients' data, if that's what the application holds). Running an unsupported version is irresponsible, frankly. Upgrading is not that hard, in most cases, and certainly the impact can be tested. Even if it's not your responsibility, you should make them aware that you think it's a bad practice.
– ADyson
Nov 20 '18 at 15:40
Anyway, I added a simple alternative solution as an extra part of the answer.
– ADyson
Nov 20 '18 at 15:42
Anyway, I added a simple alternative solution as an extra part of the answer.
– ADyson
Nov 20 '18 at 15:42
|
show 1 more comment
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53395446%2fpick-a-particular-field-out-of-an-inner-array%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
2
because you exploded each individual section, not the whole thing. Wait until you've added commas to everything, and then explode the whole line
– ADyson
Nov 20 '18 at 14:43
I did not understand, i have to add the ',' in the $data ?
– Nico
Nov 20 '18 at 14:45
You added it to the $value. not the $data. and then you exploded the $value. So fine, add it to $value. But then don't do the explode until after the loop. Unless I misunderstood. What is the content of $toto? It's not 100% clear where you are starting from, exactly.
– ADyson
Nov 20 '18 at 14:45
var_dump($toto) = array(13) { [0]=> array(1) { ["name"]=> string(15) "Prise en charge" } [1]=> array(1) { ["name"]=> string(16) "Liste des dépôts" } [2]=> array(1) { ["name"]=> string(19) "Saisie par flashage" } [3]=> array(1) { ["name"]=> string(11) "Supervision" } [4]=> array(1) { ["name"]=> string(20) "Supervision des flux" } [5]=> array(1) { ["name"]=> string(28) "Suivi des flux informatiques" } [6]=> array(1) { ["name"]=> string(14) "Administration" } [7]=> array(1) { ["name"]=> string(17) "Contrôle des RADM" }
– Nico
Nov 20 '18 at 14:48
I retrieve my SQL query in my $toto and i want to isolate the text, that's why i used 2 foreach
– Nico
Nov 20 '18 at 14:50