草庐IT

build-all

全部标签

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 - 拉维尔 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 - 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 - (Docker) 收到错误 : docker-php-source: no such file or directory when building docker file

当我尝试构建docker文件时:https://github.com/docker-library/php/blob/3f43309a0d5a427f54dc885e0812068ee767c03e/7.1/Dockerfile命令:dockerbuild-tphp_image.我遇到了以下错误:Step14:COPYdocker-php-source/usr/local/bin/lstatdocker-php-source:nosuchfileordirectory谁能帮我找出问题所在?谢谢 最佳答案 您没有正确的dockerbu

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

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

php - 使用 php preg_match_all 和 cURL 从多个页面抓取/下载图像

所以我想从另一个网站抓取一些图片,问题是每张图片都在不同的页面上IE:id/1,id/2,id/3等等到目前为止,我有下面的代码可以从给定的单个URL中获取图像:$returned_content=get_data('http://somedomain.com/id/1/');但需要将上面的行变成一个数组(我猜),这样它会从第1页抓取图像,然后继续抓取第2页上的下一张图像,然后自动抓取第3页等functionget_data($url){$ch=curl_init();$timeout=5;curl_setopt($ch,CURLOPT_URL,$url);curl_setopt($c