2016-08-22 54 views
0

大家好我正在尋找一種方式來獲得一個變量的值,但我只能和喜歡如何從一個陣列symfony2.8值

$prixArrayArticle = $article->getArticlePlateforme()->getValues(); 
dump($prixArrayArticle); 

數組給我

ReassortController.php on line 1149: 
array:1 [▼ 
0 => ArticlePlateforme {#1469 ▼ 
-article: Article {#1321 ▶} 
-plateforme: Plateforme {#1051 ▶} 
-codeProduitGv: "365717   " 
-fournisseurCommun: FournisseurAchatsAdherents {#1445 ▶} 
-referenceFournisseur: "100050   " 
-minimumCommande: 1 
-colisage: 12 
-qtePalette: 12 
-decolisable: true 
-stock: 182 
-dateCreation: DateTime {#1326 ▶} 
-present: true 
-articleSubstitution: null 
-prix: PersistentCollection {#1430 ▼ 
    -snapshot: array:1 [ …1] 
    -owner: ArticlePlateforme {#1469} 
    -association: array:19 [ …19] 
    -em: EntityManager {#137 …11} 
    -backRefFieldName: null 
    -typeClass: ClassMetadata {#1261 …} 
    -isDirty: false 
    #collection: ArrayCollection {#1439 ▼ 
    -elements: array:1 [▼ 
     0 => Prix {#1412 ▼ 
     -id: 4175988 
     -dateDebut: DateTime {#1325 ▶} 
     -dateFin: DateTime {#1324 ▶} 
     -prixNet: "4.970" 
     -prixVenteConseille: null 
     -quantiteMinimum: null 
     -type: "permanent" 
     -numeroPromo: null 
     -offreComplementaire: false 
     -minimumCommande: 0 
     -colisage: 0 
     -invisible: null 
     -present: true 
     } 
    ] 
    } 
    #initialized: true 
} 
-prixPromo: PersistentCollection {#1399 ▶} 
} 
] 

$article = $requeteArticle->getQuery()->getSingleResult(); 

給我這個

ReassortController.php on line 1129: 
Article {#769 ▼ 
-id: 1000940 
-nom: "FILM DE PAILLAGE FRAISES FRESAFILM 1M40X10M" 
-nomCourt: "FILM PAILLAGE FRAISES 1M40X10M" 
-gamme: 5 
-ecoContribution: "0.00" 
-ecoMobilier: "0.00" 
-quantiteAchat: "1.00" 
-nombreUvParUa: "1.00" 
-prixVenteConseille: "9.50" 
-present: true 
-tauxTva: TauxTva {#908 ▶} 
-marque: null 
-articleGencod: PersistentCollection {#1007 ▶} 
-sousFamille: SousFamille {#635 ▶} 
-articlePlateforme: PersistentCollection {#960 ▶} 
-uniteAchat: UniteConditionnement {#833 ▶} 
-uniteVente: UniteConditionnement {#833 ▶} 
} 

我怎樣才能獲得例如名稱值的變量,因爲該數組只有一個指標,我真的不知道怎麼去用值這個數組

回答

0

假設性得到保護,你對他們有干將在ArticlePlateforme和Article類,你應該能夠讓他們這樣的:

$articleName = $prixArrayArticle[0]->getArticle()->getNom(); 

否則,如果屬性是公開的,你可以簡單地讓他們喜歡:

$articleName = $prixArrayArticle[0]->article->nom; 
+0

這是可以的名稱(我發現它10分鐘前),但爲-prixNet:我不找到 –

+0

的方式我相信 $ prices = $ prixArrayArticle [0] - > getPrix() - > toArray (); 應該給你一個數組(「0」=> array(「prixNet」=>「4.970」,...)) – igorshmigor