<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; PHP: Анонимные массивы]]></title>
	<link rel="self" href="http://forum.script-coding.com/extern.php?action=feed&amp;tid=10842&amp;type=atom" />
	<updated>2018-08-29T17:41:03Z</updated>
	<generator>PunBB</generator>
	<id>http://forum.script-coding.com/viewtopic.php?id=10842</id>
		<entry>
			<title type="html"><![CDATA[Re: PHP: Анонимные массивы]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=128325#p128325" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>UNDYING пишет:</cite><blockquote><p>Неплохо бы уточнить, какой версии PHP</p></blockquote></div><p>5.2.</p><p>Спасибо, подтверждаю, что при переключении на PHP 5.4,<br /></p><div class="quotebox"><cite>wisgest пишет:</cite><blockquote><div class="codebox"><pre><code>echo apache_request_headers()[&#039;User-Agent&#039;];</code></pre></div></blockquote></div><p>начинает работать.</p><div class="quotebox"><cite>UNDYING пишет:</cite><blockquote><p><a href="http://php.net/manual/en/migration54.new-features.php">&quot;пруф&quot;, 3-я строчка - &quot;Function array dereferencing has been added, e.g. foo()[0]&quot;</a></p></blockquote></div><p>Есть и <a href="http://php.net/manual/ru/migration54.new-features.php">на русском</a>:<br /></p><div class="quotebox"><blockquote><p>PHP 5.4.0 предлагает широкий спектр новых возможностей: <br /></p><ul><li><p>Добавлена возможность разыменования массивов, возвращаемых функциями. Например: <em>foo()[0]</em>.</p></li></ul></blockquote></div>]]></content>
			<author>
				<name><![CDATA[wisgest]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=3850</uri>
			</author>
			<updated>2018-08-29T17:41:03Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=128325#p128325</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: PHP: Анонимные массивы]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=96563#p96563" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>wigest пишет:</cite><blockquote><p>&lt;...&gt;одной строкой&lt;...&gt;то чего в ней не хватает?</p></blockquote></div><p><a href="http://stackoverflow.com/questions/1459377/access-array-returned-by-a-function-in-php">Варианты решений.</a> Неплохо бы уточнить, какой версии PHP, что за ос/&quot;репы&quot;.<br />По ссылке пишут, что напрямую по имени обратиться нельзя (пока?), но в PHP5.4 можно обратиться к эл-ту возвращаемого массива через индекс (и в первом комментарии - <em>&quot;I&#039;ve got PHP 5.4.11-1~precise+1 and this feature doesn&#039;t work! Got message in response Parse error: syntax error, unexpected &#039;[&#039;&quot;</em> - либо сборщики пакета &quot;накосячили&quot;, либо автор чего-то недоговаривает).<br />Т.е. как-то так (<a href="http://php.net/manual/en/migration54.new-features.php">&quot;пруф&quot;, 3-я строчка - &quot;Function array dereferencing has been added, e.g. foo()[0]&quot;</a>): </p><div class="codebox"><pre><code>echo apache_request_headers()[1];</code></pre></div><p>Кстати,&nbsp; м.б. в 5.5 и/или 5.6 что-нибудь добавили, &quot;навскидку&quot; упоминаний не нашёл.</p><p>PS: Попробовать особо негде (оч. давно ничего не пишу на PHP), и заранее прошу прощения за &quot;некропостинг&quot;.</p>]]></content>
			<author>
				<name><![CDATA[UNDYING]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=27822</uri>
			</author>
			<updated>2015-08-17T23:49:01Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=96563#p96563</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[PHP: Анонимные массивы]]></title>
			<link rel="alternate" href="http://forum.script-coding.com/viewtopic.php?pid=96166#p96166" />
			<content type="html"><![CDATA[<p>Функция возвращает массив. Можно ли, не запоминая в переменной возвращаемое функцией значение-массив, на ходу получить его элемент. Например, если переписать<br /></p><div class="codebox"><pre><code>$request_headers = apache_request_headers();
echo $request_headers[&#039;User-Agent&#039;];</code></pre></div><p>одной строкой </p><div class="codebox"><pre><code>echo apache_request_headers()[&#039;User-Agent&#039;];</code></pre></div><p>то чего в ней не хватает?</p>]]></content>
			<author>
				<name><![CDATA[wisgest]]></name>
				<uri>http://forum.script-coding.com/profile.php?id=3850</uri>
			</author>
			<updated>2015-08-01T08:53:35Z</updated>
			<id>http://forum.script-coding.com/viewtopic.php?pid=96166#p96166</id>
		</entry>
</feed>
