--- id: php-arrays-access title: "PHP Arrays Access" category: "Programming_Language" status: "draft" verification_status: "conceptual" canonical_id: "" aliases: ["PHP λ°°μ—΄ μ ‘κ·Ό"] duplicate_of: "" source_trust_level: "B" confidence_score: 0.88 created_at: 2026-07-04 updated_at: 2026-07-04 review_reason: "" merge_history: [] tags: ["php", "programming", "w3schools", "arrays", "access"] raw_sources: ["https://www.w3schools.com/php/php_arrays_access.asp"] applied_in: [] github_commit: "" --- # [[PHP Arrays Access]] ## 🎯 ν•œ 쀄 톡찰 (One-line insight) An array item can hold a function NAME as a string, and calling `$myArr[2]()` actually invokes that named function β€” this dynamic-call pattern (storing a callable's name and invoking it via array access + parentheses) is a lightweight precursor to PHP's full callback-function mechanism covered later. [S1] ## 🧠 핡심 κ°œλ… (Core concepts) - **Access by index (indexed array)** β€” `$cars[2]`. [S1] - **Access by key (associative array)** β€” `$cars["year"]`. [S1] - **Double or single quotes** β€” both work identically for key access: `$cars["model"]` / `$cars['model']`. [S1] - **Executing a function stored as an array item** β€” `$myArr[2]();` calls the function whose name is stored at that index. [S1] - **`foreach`** β€” standard iteration for both indexed and associative arrays. [S1] ## πŸ“– μ„ΈλΆ€ λ‚΄μš© (Details) - Indexed access: `$cars = array("Volvo", "BMW", "Toyota"); echo $cars[2]; // "Toyota"`. [S1] - Associative access: `$cars = array("brand" => "Ford", "model" => "Mustang", "year" => 1964); echo $cars["year"];`. [S1] - Function-name-as-array-item, invoked: `function myFunction() { echo "I come from a function!"; } $myArr = array("Volvo", 15, "myFunction"); $myArr[2]();`. [S1] - Same pattern via associative key: `$myArr = array("car" => "Volvo", "age" => 15, "message" => "myFunction"); $myArr["message"]();`. [S1] ## βš–οΈ λͺ¨μˆœ 및 μ—…λ°μ΄νŠΈ (Contradictions & updates) μ†ŒμŠ€μ—μ„œ λͺ¨μˆœλ˜λŠ” μ •λ³΄λŠ” λ°œκ²¬λ˜μ§€ μ•ŠμŒ. ## πŸ› οΈ 적용 사둀 (Applied in summary) ν˜„μž¬ 발견된 μ‹€μ œ 적용 사둀가 μ—†μŠ΅λ‹ˆλ‹€ β€” 배열에 μ €μž₯된 ν•¨μˆ˜ 이름을 인덱슀둜 ν˜ΈμΆœν•˜λŠ” νŒ¨ν„΄μ΄ 콜백 ν•¨μˆ˜(Callback Functions) μ±•ν„°λ‘œ μ΄μ–΄μ§€λŠ” μ˜ˆκ³ νŽΈμ΄λ‹€. [S1] ## πŸ’» μ½”λ“œ νŒ¨ν„΄ (Code patterns) Invoking a function whose name is stored as an array item (PHP): ```php function myFunction() { echo "I come from a function!"; } $myArr = array("Volvo", 15, "myFunction"); $myArr[2](); // calls myFunction() ``` ## βœ… 검증 μƒνƒœ 및 신뒰도 - **μƒνƒœ:** draft - **검증 단계:** conceptual - **좜처 신뒰도:** B (W3Schools β€” widely used educational reference, not a primary standards body) - **μ‹ λ’° 점수:** 0.88 - **쀑볡 검사 κ²°κ³Ό:** μ‹ κ·œ 생성 (New discovery) ## πŸ”— 지식 κ·Έλž˜ν”„ (Knowledge Graph) - **μƒμœ„/루트:** [[PHP Tutorial]] - **κ΄€λ ¨ κ°œλ…:** [[PHP Arrays Create]], [[PHP Arrays Update]], [[PHP Callback Functions]] - **μ°Έμ‘° λ§₯락:** λ°°μ—΄ ν•­λͺ© μ ‘κ·Ό 및 ν•¨μˆ˜ μ‹€ν–‰ β€” λ°°μ—΄ μˆ˜μ •(Update) μ±•ν„°λ‘œ 이어짐. ## πŸ“š 좜처 (Sources) - [S1] W3Schools β€” PHP Access Arrays β€” https://www.w3schools.com/php/php_arrays_access.asp ## πŸ“ λ³€κ²½ 이λ ₯ (Change history) - 2026-07-04: Initial draft synthesized from the W3Schools "PHP Access Arrays" page (Astra wiki-curation, P-Reinforce v3.1 format).