PHP 阵列处理

定义和用法

PHP extract() 函数从数组中把变量导入到当前的符号表中。

对于数组中的每个元素,键名用于变量名,键值用于变量值。

第二个参数 type 用于指定当某个变量已经存在,而数组中又有同名元素时,extract() 函数如何对待这样的冲突。

本函数返回成功设置的变量数目。

 

语法

extract(array,extract_rules,prefix)
 

例子 1

<?php
$a = 'Original';
$my_array = array("a" => "Cat","b" => "Dog", "c" => "Horse");
extract($my_array);
echo "\$a = $a; \$b = $b; \$c = $c";
?>
 

输出:

$a = Cat; $b = Dog; $c = Horse
----------------------------------------------------------------------------------------------------
描述 
    
    
array token_get_all ( string $source ) 阵列 token_get_all( 字符串 $源

token_get_all() parses the given source string into PHP language tokens using the Zend engine's lexical scanner. token_get_all()解析成PHP语言定字符串标记使用Zend引擎的词汇扫描仪。

 

例子1 token_get_all()例子

DE> <?php
$tokens
= token_get_all ( '<?php echo; ?>' );
/* => array(
array(T_OPEN_TAG, '<?php'),
array(T_ECHO, 'echo'),
';',
array(T_CLOSE_TAG, '?>') ); */

/* Note in the following example that the string is parsed as T_INLINE_HTML
rather than the otherwise expected T_COMMENT (T_ML_COMMENT in PHP <5).
This is because no open/close tags were used in the "code" provided.
This would be equivalent to putting a comment outside of <?php ?> tags in a normal file. */
$tokens = token_get_all ( '/* comment */' );
// => array(array(T_INLINE_HTML, '/* comment */'));
?>
DE>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值