--- id: php-arrays-create title: "PHP Arrays Create" category: "Programming_Language" status: "draft" verification_status: "conceptual" canonical_id: "" aliases: ["array() vs []", "PHP λ°°μ—΄ 생성"] duplicate_of: "" source_trust_level: "B" confidence_score: 0.9 created_at: 2026-07-04 updated_at: 2026-07-04 review_reason: "" merge_history: [] tags: ["php", "programming", "w3schools", "arrays", "create"] raw_sources: ["https://www.w3schools.com/php/php_arrays_create.asp"] applied_in: [] github_commit: "" --- # [[PHP Arrays Create]] ## 🎯 ν•œ 쀄 톡찰 (One-line insight) Indexed and associative arrays are structurally IDENTICAL under the hood β€” an indexed array is just an associative array whose keys happen to be auto-assigned sequential integers (`0 => "Volvo", 1 => "BMW"`), and you can even mix numeric and named keys freely in the same array, since PHP doesn't enforce a hard boundary between the two "types." [S1] ## 🧠 핡심 κ°œλ… (Core concepts) - **`array()`** vs **`[]`** β€” functionally identical; brackets are the shorter modern syntax. [S1] - **Multi-line declarations** β€” line breaks don't matter inside an array literal. [S1] - **Trailing comma** β€” allowed after the last item. [S1] - **Auto-assigned indices** β€” indexed arrays are secretly `0 => val, 1 => val, ...` associative arrays. [S1] - **Empty array + incremental fill** β€” `$cars = []; $cars[0] = "Volvo"; ...`. [S1] - **Mixed keys** β€” an array can combine numeric indices and named keys simultaneously. [S1] ## πŸ“– μ„ΈλΆ€ λ‚΄μš© (Details) - Shorthand brackets: `$cars = ["Volvo", "BMW", "Toyota"];`. [S1] - Explicit index-key equivalence: `$cars = [0 => "Volvo", 1 => "BMW", 2 =>"Toyota"];` β€” same as auto-indexed. [S1] - Empty then fill (indexed): `$cars = []; $cars[0] = "Volvo"; $cars[1] = "BMW"; $cars[2] = "Toyota";`. [S1] - Empty then fill (associative): `$myCar = []; $myCar["brand"] = "Ford"; $myCar["model"] = "Mustang";`. [S1] - Mixed keys: `$myArr = []; $myArr[0] = "apples"; $myArr[1] = "bananas"; $myArr["fruit"] = "cherries";`. [S1] ## βš–οΈ λͺ¨μˆœ 및 μ—…λ°μ΄νŠΈ (Contradictions & updates) - **인덱슀 λ°°μ—΄κ³Ό μ—°κ΄€ λ°°μ—΄μ˜ ꡬ쑰적 동일성**: 인덱슀 배열은 사싀 숫자 ν‚€(0, 1, 2...)λ₯Ό μžλ™ 할당받은 μ—°κ΄€ 배열일 λΏμ΄λΌλŠ” 점이 예제둜 직접 증λͺ…됨. [S1] ## πŸ› οΈ 적용 사둀 (Applied in summary) ν˜„μž¬ 발견된 μ‹€μ œ 적용 사둀가 μ—†μŠ΅λ‹ˆλ‹€ β€” 숫자 μΈλ±μŠ€μ™€ λͺ…λͺ…λœ ν‚€λ₯Ό ν•œ 배열에 ν˜Όμš©ν•˜λŠ” νŒ¨ν„΄μ΄ μœ μ—°ν•œ 데이터 ꡬ쑰 μ„€κ³„μ˜ μ‹€μ „ 사둀닀. [S1] ## πŸ’» μ½”λ“œ νŒ¨ν„΄ (Code patterns) Mixed numeric and named keys in one array (PHP): ```php $myArr = []; $myArr[0] = "apples"; $myArr[1] = "bananas"; $myArr["fruit"] = "cherries"; ``` ## βœ… 검증 μƒνƒœ 및 신뒰도 - **μƒνƒœ:** draft - **검증 단계:** conceptual - **좜처 신뒰도:** B (W3Schools β€” widely used educational reference, not a primary standards body) - **μ‹ λ’° 점수:** 0.90 - **쀑볡 검사 κ²°κ³Ό:** μ‹ κ·œ 생성 (New discovery) ## πŸ”— 지식 κ·Έλž˜ν”„ (Knowledge Graph) - **μƒμœ„/루트:** [[PHP Tutorial]] - **κ΄€λ ¨ κ°œλ…:** [[PHP Arrays Indexed]], [[PHP Arrays Associative]], [[PHP Arrays Access]] - **μ°Έμ‘° λ§₯락:** λ°°μ—΄ 생성 문법 β€” λ°°μ—΄ μ ‘κ·Ό(Access) μ±•ν„°λ‘œ 이어짐. ## πŸ“š 좜처 (Sources) - [S1] W3Schools β€” PHP Create Arrays β€” https://www.w3schools.com/php/php_arrays_create.asp ## πŸ“ λ³€κ²½ 이λ ₯ (Change history) - 2026-07-04: Initial draft synthesized from the W3Schools "PHP Create Arrays" page (Astra wiki-curation, P-Reinforce v3.1 format).