如何将哈希推入到PHP数组中? [英] How to push hash into array of hash in php?

查看:124
本文介绍了如何将哈希推入到PHP数组中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

像array_push()我们可以将元素推入数组。我想推送一个散列[名称,网址]到一个散列数组。

解决方案

如果我明白你的问题,你想要从URL中检索哈希值,然后使用 PHP_URL_FRAGMENT 参数使用 parse_url

  $ url ='http:// username:password @ hostname / path?arg = value#anchor'; 

print_r(parse_url($ url));

echo parse_url($ url,PHP_URL_FRAGMENT);

将返回

  [fragment] =>锚点

参考资料


Like array_push() where we can push an element in to array. I want to push an hash [name,url] in to an array of hash.

解决方案

ifif i understand your problem, you want to retrieve hash value from a url then use parse_url with PHP_URL_FRAGMENT argument

$url = 'http://username:password@hostname/path?arg=value#anchor';

print_r(parse_url($url));

echo parse_url($url, PHP_URL_FRAGMENT);

will return

 [fragment] => anchor

Reference

这篇关于如何将哈希推入到PHP数组中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆