concatenar array en php

Iniciado por asdexiva, 14 Mayo 2020, 15:51 PM

0 Miembros y 1 Visitante están viendo este tema.

asdexiva

alguien me puede ayudar en esto

arr = ['66', '59', '07/05/2', '020', '07:13', 'a.m.', '135.00 - - 135.00', '66', '61', '07/05/2', '020', '07:15', 'a.m.', '120.00 - - 120.00', '66', '62', '07/05/2', '020', '07:31', 'a.m.', '75.00 - - 75.00', '66', '64', '07/05/2', '020', '07:41', 'a.m.', '60.00 - - 60.00', '66', '65', '07/05/2', '020', '07:44', 'a.m.', '45.00 - - 45.00', '66', '66', '07/05/2', '020', '07:54', 'a.m.', '65.00 - - 65.00', '66', '67', '07/05/2', '020', '08:03', 'a.m.', '90.00 - - 90.00', '66', '68', '07/05/2', '020', '08:06', 'a.m.', '135.00 - - 135.00', '66', '70', '07/05/2', '020', '08:10', 'a.m.', '95.00 - - 95.00', '66', '71', '07/05/2', '020', '08:15', 'a.m.', '0.00 - - 0.00', '66', '72', '07/05/2', '020', '08:18', 'a.m.', '0.00 - - 0.00', '66', '73', '07/05/2', '020', '08:18', 'a.m.', '0.00 - - 0.00', '66', '74', '07/05/2', '020', '08:21', 'a.m.', '85.00 - - 85.00', '66', '75', '07/05/2', '020', '08:26', 'a.m.', '0.00 - - 0.00', '66', '77', '07/05/2', '020', '08:30', 'a.m.', '240.00 - - 240.00', '66', '78', '07/05/2', '020', '08:43', 'a.m.', '45.00 - - 45.00', '66', '79', '07/05/2', '020', '08:44', 'a.m.', '145.00 - - 145.00', '66', '80', '07/05/2', '020', '08:45', 'a.m.', '250.00 - - 250.00', '66', '81', '07/05/2', '020', '08:51', 'a.m.', '45.00 - - 45.00', '66', '82', '07/05/2', '020', '08:54', 'a.m.', '190.00 - - 190.00', '66', '84', '07/05/2', '020', '08:56', 'a.m.', '120.00 - - 120.00', '66', '85', '07/05/2', '020', '08:57', 'a.m.', '170.00 - - 170.00', '66', '86', '07/05/2', '020', '08:59', 'a.m.', '30.00 - - 30.00', '66', '87', '07/05/2', '020', '09:02', 'a.m.', '140.00 - - 140.00', '66', '88', '07/05/2', '020', '09:02', 'a.m.', '175.00 - - 175.00', '66', '89', '07/05/2', '020', '09:16', 'a.m.', '125.00 - - 125.00', '66', '90', '07/05/2', '020', '09:18', 'a.m.', '105.00 - - 105.00', '66', '91', '07/05/2', '020', '09:25', 'a.m.', '75.00 - - 75.00', '66', '92', '07/05/2', '020', '09:27', 'a.m.', '75.00 - - 75.00', '66', '94', '07/05/2', '020', '09:28', 'a.m.', '145.00 - - 145.00', '66', '95', '07/05/2', '020', '09:29', 'a.m.', '100.00 - - 100.00', '66', '97', '07/05/2', '020', '09:31', 'a.m.', '145.00 - - 145.00', '66', '98', '07/05/2', '020', '09:30', 'a.m.', '135.00 - - 135.00', '66', '99', '07/05/2', '020', '09:44', 'a.m.', '30.00 - - 30.00', '67', '01', '07/05/2', '020', '09:47', 'a.m.', '35.00 - - 35.00', '67', '02', '07/05/2', '020', '09:47', 'a.m.', '75.00 - - 75.00', '67', '03', '07/05/2', '020', '09:49', 'a.m.', '320.00 - - 320.00', '67', '04', '07/05/2', '020', '09:48', 'a.m.', '125.00 - - 125.00', '67', '05', '07/05/2', '020', '09:51', 'a.m.', '25.00 - - 25.00', '67', '07', '07/05/2', '020', '09:54', 'a.m.', '150.00 - - 150.00', '67', '08', '07/05/2', '020', '09:55', 'a.m.', '45.00 - - 45.00', '67', '09', '07/05/2', '020', '09:57', 'a.m.', '45.00 - - 45.00', '67', '10', '07/05/2', '020', '10:08', 'a.m.', '150.00 - - 150.00', '67', '13', '07/05/2', '020', '10:16', 'a.m.', '130.00 - - 130.00', '67', '14', '07/05/2', '020', '10:17', 'a.m.', '75.00 - - 75.00', '67', '15', '07/05/2', '020', '10:18', 'a.m.', '100.00 - - 100.00', '67', '16', '07/05/2', '020', '10:20', 'a.m.', '125.00 - - 125.00', '67', '18', '07/05/2', '020', '10:20', 'a.m.', '185.00 - - 185.00', '67', '19', '07/05/2', '020', '10:22', 'a.m.', '60.00 - - 60.00', '67', '21', '07/05/2', '020', '10:31', 'a.m.', '60.00 - - 60.00', '67', '23', '07/05/2', '020', '10:44', 'a.m.', '140.00 - - 140.00', '67', '24', '07/05/2', '020', '10:47', 'a.m.', '400.00 - - 400.00', '67', '26', '07/05/2', '020', '10:55', 'a.m.', '80.00 - - 80.00', '67', '28', '07/05/2', '020', '10:59', 'a.m.', '75.00 - - 75.00', '67', '29', '07/05/2', '020', '11:00', 'a.m.', '150.00 - - 150.00', '67', '32', '07/05/2', '020', '11:18', 'a.m.', '0.00 - - 0.00', '67', '33', '07/05/2', '020', '11:32', 'a.m.', '115.00 - - 115.00', '67', '34', '07/05/2', '020', '11:44', 'a.m.', '85.00 - - 85.00', '67', '35', '07/05/2', '020', '11:51', 'a.m.', '40.00 - - 40.00', '67', '36', '07/05/2', '020', '11:54', 'a.m.', '170.00 - - 170.00', '67', '37', '07/05/2', '020', '12:11', 'p.m.', '0.00 - - 0.00', '67', '38', '07/05/2', '020', '12:11', 'p.m.', '140.00 - - 140.00', '67', '39', '07/05/2', '020', '12:16', 'p.m.', '90.00 - - 90.00', '67', '41', '07/05/2', '020', '12:23', 'p.m.', '70.00 - - 70.00', '67', '42', '07/05/2', '020', '12:26', 'p.m.', '50.00 - - 50.00', '67', '45', '07/05/2', '020', '12:25', 'p.m.', '65.00 - - 65.00', '67', '46', '07/05/2', '020', '12:28', 'p.m.', '60.00 - - 60.00', '67', '47', '07/05/2', '020', '12:31', 'p.m.', '60.00 - - 60.00', '67', '49', '07/05/2', '020', '12:37', 'p.m.', '45.00 - - 45.00', '67', '50', '07/05/2', '020', '12:38', 'p.m.', '20.00 - - 20.00', '67', '51', '07/05/2', '020', '12:39', 'p.m.', '60.00 - - 60.00', '67', '52', '07/05/2', '020', '12:44', 'p.m.', '75.00 - - 75.00', '67', '53', '07/05/2', '020', '12:46', 'p.m.', '40.00 - - 40.00', '67', '54', '07/05/2', '020', '12:54', 'p.m.', '100.00 - - 100.00', '67', '55', '07/05/2', '020', '12:56', 'p.m.', '65.00 - - 65.00', '67', '56', '07/05/2', '020', '01:01', 'p.m.', '60.00 - - 60.00', '67', '57', '07/05/2', '020', '01:03', 'p.m.', '45.00 - - 45.00', '67', '58', '07/05/2', '020', '01:04', 'p.m.', '130.00 - - 130.00', '67', '59', '07/05/2', '020', '01:14', 'p.m.', '240.00 - - 240.00', '67', '60', '07/05/2', '020', '01:20', 'p.m.', '90.00 - - 90.00', '67', '61', '07/05/2', '020', '01:20', 'p.m.', '15.00 - - 15.00', '67', '62', '07/05/2', '020', '01:21', 'p.m.', '75.00 - - 75.00', '67', '63', '07/05/2', '020', '01:36', 'p.m.', '30.00 - - 30.00', '67', '64', '07/05/2', '020', '01:41', 'p.m.', '40.00 - - 40.00', '67', '65', '07/05/2', '020', '01:43', 'p.m.', '60.00 - - 60.00', '67', '66', '07/05/2', '020', '01:53', 'p.m.', '65.00 - - 65.00', '67', '67', '07/05/2', '020', '01:58', 'p.m.', '155.00 - - 155.00', 'Tickets: 87 8295 - - 8,295.00', 'Totals', 'Efectivo 1,584.00', 'Tarjeta de Cr\xc3\xa9dito 0.00', 'Ingresos Efectivo 510.00', 'Ingresos Tarjeta de Cr\xc3\xa9dito 0.00', 'Gastos Total 7,221.00', 'Gastos Tarjeta de Cr\xc3\xa9dito 0.00', 'Total de Efectivo en Gaveta -6,711.00']

tengo este array pero mi duda es como puedo concatenar los 2 primeros elementos cada 6
a que me refiero a estos  66', '59'  66', '59'  '66', '62' y asi susecivamente si alguien pudiera ayduarme gracias

#!drvy

Yo no te acabo de entender.. podrias dar un ejemplo más concreto?

Los temas de PHP van al subforo de PHP..

Saludos

EdePC

Saludos,

- Yo he entendido que quieres un array que tenga los mismos elementos, pero que los dos primeros y luego cada múltiplo de 7 deben ir concatenados, más o menos así:

66 59
07/05/2
020
07:13
a.m.
135.00 - - 135.00
66 61
07/05/2
020
07:15
a.m.
120.00 - - 120.00
66 62
07/05/2
020
07:31
a.m.
75.00 - - 75.00
...


- Según he probado se puede obtener con:

Código (php-brief) [Seleccionar]
$arr2 = [];
for ($i = 0; $i < count($arr); $i++) {
  if ($i == 0 || $i % 7 == 0) {
    $arr2[] = $arr[$i] . ' ' . $arr[++$i];
  } else {
    $arr2[] = $arr[$i];
  }
}

foreach ($arr2 as $i) {
  echo "$i<br>";
}