草庐IT

all-native

全部标签

php - 使用 preg_match_all 匹配模式并排除子字符串

我需要找到位于START和END之间的所有字符串,从匹配的字符串中排除PADDING子字符串。我发现的最好方法是$r="stuffSTARTthisPADDINGisENDstuffstuffSTARTwhatPADDINGIwantPADDINGtoPADDINGfindENDstuff";preg_match_all('/START(.*?)END/',str_replace('PADDING','',$r),$m);print(join($m[1]));>thisiswhatIwanttofind我想用尽可能小的代码来做到这一点:有一个更短的只有preg_match_all没有s

php - Symfony2 和 Doctrine2 : how to get all tags for a post?

在我的项目中,我在两个实体之间建立了多对多关系:Post和Tag。(帖子有一个变量“标签”)。我想允许用户通过他们的名字或他们的标签搜索帖子(例如在tumblr上)假设我的数据库中有这个:NameTagspost1:"Recipewitheggs"cooking,chicken,eggpost2:"RandomTitle"beef,chicken,eggpost3:"CookingFish"fish,cookingpost4:"Riceandchicken"rice,meat因此,如果我在搜索表单中输入“鸡蛋”,我必须只返回post1(因为标签)、post2(因为标签)和post4(因

php - [Microsoft][SQL Server Native Client 11.0]共享内存提供程序 : Timeout error [258]

美好的一天。我在php5上有网站。所有查询均使用sqlsrv执行;当我进行查询时出现错误:[Microsoft][SQLServerNativeClient11.0]SharedMemoryProvider:Timeouterror[258]如何修复错误? 最佳答案 此错误可能是由于连接速度非常慢或SQL查询耗时过长造成的。这不是SQLServer的问题。尝试在PHP的connectionString中扩展超时值。SeethispreviousanswerYouneedtochangesomesettinginyourphp.ini

php - 拉维尔 5 : Get all passed data in view template

目标是我想将ALL传递的数据从Controller传递到单个全局JavaScript变量中的View,这是一个示例:在Controller中index(){returnveiw('path.to.view',['data1'=>$data1,'data2'=>$data2]);}在View中var_backendData={!!$allData!!}//$allDatashouldcontainALLthepasseddatafromthecontroller我将从Controller接收到的所有数据存储在$allData中 最佳答案

php - preg_match_all html 标签,双引号或单引号中的标签除外

给定这个DOM$html=Bye","info":"Wewin"}'>TheAAnythinghere"}'>EOD;我正在尝试使用此表达式来preg_match_allhtml标签:$tags=array();if(preg_match_all('~]*>|~im',$html,$matchall,PREG_SET_ORDER)){foreach($matchallas$m){$tags[]=$m[0];}}print_r($tags);这个表达式的输出是:Array([0]=>[1]=>[2]=>[3]=>[4]=>[5]=>[6]=>[7]=>[8]=>[9]=>[10]=>[1

php - 升级在 PHP 中 native 实现的 Olson tz 数据库

我在一个大量使用时区的网站上工作,该网站需要处于可用的绝对最新tz信息的最前沿(我已经通过tzmailinglist获得)。我不知道的是如何让PHP安装在我的开发机器和我的Web主机上运行,​​以使用更多最新的tz数据而不是它们上已有的旧数据。这不像升级PHP那样简单,因为即使是最新版本的PHP也不一定在任何给定时间都具有绝对最新的tz数据。有人指出timezonedbpackageinpecl将使我获得最新的官方发布包,但如果我需要更进一步才能获得可能尚未正式发布的更新的“前沿”怎么办?我很确定较新的tz数据必须使用zic(在tzcode中分发)进行编译,并将生成的二进制文件提供给p

php - preg_match_all( ) 在不同的服务器上表现不同

下面的代码在我的PC上的XAMPP上运行完美,但在我新买的VPS上不起作用。它使我的代码崩溃。preg_match_all("/$regex/siU",$string,$matches,PREG_SET_ORDER);这应该只是从HTML中获取链接和标题。以前,今天也出现过类似的正则表达式问题。代码在本地服务器上运行良好,但在vps上创建“连接已重置”错误。该问题是由一些注释的html(其中包含php代码)引起的,使用以下代码将其删除以优化输出,但即使连接重置的问题已解决,HTML在浏览器源代码中仍然有注释。$string=preg_replace('//','',$string);那

PHP 面向对象 : Get all declared classes which are have extended another parent class

我需要获取所有扩展了另一个父类的声明类。例如……classParentClass{}classChildOneextendsParentClass{}classChildTwoextendsParentClass{}classChildThree{}我需要一个输出这个的数组:array('ChildOne','ChildTwo')我是PHPOOP的新手,但基于一些谷歌搜索,我想到了这个解决方案。$classes=array();foreach(get_declared_classes()as$class){if(is_subclass_of($class,'ParentClass'))

用于分割字符串的 PHP preg_match_all 正则表达式

任何人都可以帮助完成我的正则表达式吗?我的字符串格式如下:{p:19}Ja?DumöchtestzurKönigin?{p:20}Hmm...DubistgekommenumdenTitelKriegerinzuerhalten?Verstehe.DasistganzschöntapferfürsoeinejungeDame.DieKöniginwirdsicherauchsehrüberraschtsein.{t:19}Bittesehr,gehdirekthinein.{t:20}TreibeDichhiernichtherum,wennDuhiernichtszusuchenha

php - Symfony2 表格 : How to display all the errors?

我想一起打印所有验证错误,而不是每个字段旁边的每个错误。但是form_errors(form)不工作。我可以打印单个错误,所以我想我可以为每个字段使用form_errors(form.some_field)。问题是它会打印类似“此字段不能为空”的错误,除非紧挨着该字段,否则这是没有意义的。有什么想法吗? 最佳答案 您应该查看error_bubbling字段属性。如果将该属性设置为true,则该字段的任何错误都将传递给父字段或表单。例如,如果在普通字段上设置为true,则该字段的任何错误都将附加到主表单,而不是特定字段。