Beo
Three Magic
- Joined
- Aug 25, 2009
- Messages
- 9,057
- Solutions
- 1
- Reaction score
- 846
Hi,
Having an issue with php array, thought I'd ask here.
I need to print three arrays to a string, without the Array brackets in the output.
I have these calls
Which is later called to a string. I am using an API which requires this field to be a STRING only. Which I have the below.
This will provide me with an output of
I need this to output to (KEEP IN MIND, I have to use Print_r() due to API)
Having an issue with php array, thought I'd ask here.
I need to print three arrays to a string, without the Array brackets in the output.
I have these calls
PHP:
$dns = array();
$dd = array();
$cn = array();
while ($row = mysqli_fetch_array($query)) {
$cn[] = $row['cn'];
$dns[] = $row['du'];
$dd[] = $row['ed'];
}
$string = array_map(function($item) {
return array_combine(['CN', 'DU', 'DD'], $item);
}, array_map(null, $cn, $dns, $dd));
Which is later called to a string. I am using an API which requires this field to be a STRING only. Which I have the below.
PHP:
$ticket = print_r($string, true);
This will provide me with an output of
Code:
Array
(
[0] => Array
(
[CN] => Otland
[DU] => Otland.net
[DD] => 2011/11/11
)
[1] => Array
(
[CN] => Tibia
[DU] => Tibia.com
[DD] => 2020/12/09
)
[2] => Array
(
[CN] => Twitch
[DU] => Twitch.tv
[DD] => 2025/11/01
)
)
I need this to output to (KEEP IN MIND, I have to use Print_r() due to API)
Code:
CN = Otland
DU = otland.net
DD = 11/11/2011
CN = Tibia
DU = Tibia.com
DD = 09/12/2020
CN = Twitch
DU = Twitch.tv
DD = 01/11/2025
Last edited: