php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #22892 Using a string as an Array parameter
Submitted: 2003-03-26 04:34 UTC Modified: 2003-03-26 09:26 UTC
From: jorgen at webstores dot nl Assigned:
Status: Not a bug Package: Unknown/Other Function
PHP Version: 4.3.2RC1 OS: Windows XP
Private report: No CVE-ID: None
 [2003-03-26 04:34 UTC] jorgen at webstores dot nl
<?php
  $var = 'ABC';
  echo ($var[0]); // Displays 'A'
  echo ($var[1]); // Displays 'B'
  echo ($var[2]); // Displays 'C'

  echo join(" ", $var); // Wont work
?>

Do you get my point? One can call a 'string' variable as an Array, but one can not use that same 'string' as an Array parameter. Seems a little bit odd to me...
Because I want to display: 'ABC' as 'A B C', would this be very handy.

Kind regards,
Jorgen Horstink

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-03-26 09:26 UTC] edink@php.net
Your have mistaken two different meanings of [] operator which can mean both string offset (as is in your example) and array.

For this reason the use of [] has been discouraged for some time and {} has been introduced as the replacement for the case of accessing string characters.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Jun 02 03:01:30 2024 UTC