Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [PHP]Tablica klucz jako ciąg znaków
lisartur
post 11.07.2015, 22:28:10
Post #1





Grupa: Zarejestrowani
Postów: 63
Pomógł: 0
Dołączył: 24.09.2009

Ostrzeżenie: (0%)
-----


Witam
Mam tablicę
$item->element['12-1212']['value']
$item->element['21-2121']['file']
$item->element['31-3323']['value']
$item->element['41-3232']['value']

jak mogę dokonać zapisu
w stylu
$item->element[dowlny_ ciąg]['file']
aby w miejsce dowolny ciąg wstawić coś jak * zastępujący dowolny ciąg
Go to the top of the page
+Quote Post
KsaR
post 11.07.2015, 22:33:04
Post #2





Grupa: Zarejestrowani
Postów: 520
Pomógł: 102
Dołączył: 15.07.2014
Skąd: NULL

Ostrzeżenie: (0%)
-----


Cytat(lisartur @ 11.07.2015, 23:28:10 ) *
Witam
Mam tablicę
$item->element['12-1212']['value']
$item->element['21-2121']['file']
$item->element['31-3323']['value']
$item->element['41-3232']['value']

jak mogę dokonać zapisu
w stylu
$item->element[dowlny_ ciąg]['file']
aby w miejsce dowolny ciąg wstawić coś jak * zastępujący dowolny ciąg


Coś w ten deseń:

  1. foreach ($item->element as $v)
  2. {
  3. echo $v['file'];
  4. }


Edit kodu, bo pomyłke zrobiłem.
Teraz powinno dzialac bo testowalem u siebie podobny kod.
Sprawdzaj ewentualnie czy indeks istnieje jesli trzeba.
  1. foreach ($item->element as $v)
  2. {
  3. echo isset($v['file']) ? $v['file'] : '';
  4. }
  5.  


Ten post edytował Ksar 11.07.2015, 22:47:13


--------------------
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 12.06.2024 - 18:02