How to access a var with "-" in PHP

Reynier

For first time I found this problem, see I've a array of objetcs and I access them as follow:

$arrayOfObjects[$pos]->value;

But my problem is that one of the array values have a "-" meaning the value is e-mail so when I do this:

$arrayOfObjects[$pos]->e-mail;

I get an error, how do I handle this? The var can't be changed!!

kalley

If you absolutely have to have the hyphens, you can access it like:

$arrayOfObjects[$pos]->{'e-mail'};

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

분류에서Dev

Access a div in a var

분류에서Dev

How to get a string from external PHP file and set it as var in JavaScript

분류에서Dev

Php if($var) used to work

분류에서Dev

PHP if ($ var) 사용

분류에서Dev

How to access the MAPI Zarafa interface in PHP?

분류에서Dev

How to access a PHP array with keys of inner values

분류에서Dev

oop php의 var 내부 var

분류에서Dev

$ var = $ var-1 PHP 문제

분류에서Dev

how to access the returned php variable using ajax, as a php variable in the view

분류에서Dev

PHP, var_export minifier

분류에서Dev

How to clean /var/cache?

분류에서Dev

How to access PDO connection object across multiple class?[php +Mysql]

분류에서Dev

How to search for for strings/keywords in Access database using PHP?

분류에서Dev

"if (! isset ($ var)) $ var = 1;"에 대한 PHP 속기

분류에서Dev

PHP var 및 HTML 양식

분류에서Dev

Javascript var에서 PHP로

분류에서Dev

JavaScript로 PHP var 전달

분류에서Dev

PHP의 var_export 문제

분류에서Dev

isset($var) - BLADE versus raw php

분류에서Dev

PHP var로 삭제 확인

분류에서Dev

PHP Post vars to var names ok with PDO?

분류에서Dev

laravel 4 HAML 파일 + php var

분류에서Dev

PHP 변수 var_dump = NULL?

분류에서Dev

How to access attributes of php object inside a array of php objects from javascript

분류에서Dev

PHP access system - OR in function

분류에서Dev

How to update scope var from Math expression and another scope var?

분류에서Dev

Why doesn't ssh record failed access in /var/log/btmp?

분류에서Dev

SAS: how to move cell content from Var2 to Var1 if Var1 is empty

분류에서Dev

AWStats: cannot access /var/log/apache2/access.log