Friday, April 27, 2012

Re: Get the first link of a post ?

On Thu, Apr 26, 2012 at 17:53, JonStark <jeanfau@gmail.com> wrote:
> I'm currently trying to get the first link of a post for a specific post
> format, but preg_match needs two parameters and I can't find the second...
> Here is my code :

The second parameter is the thing you want to find a match in, I think
they call it the haystack in the documentation.


> } else if (($post['Post']['format']) == 'link') {
> if (preg_match('/<a\s[^>]*?href=[\'"](.+?)[\'"]/is')a) {
> return $firstLink;
> } else {
> return $articleLink;
> }
>
> (...)
>
> How can I make this work in my view ? Thanks a lot.

What are you matching against? Is it something in the $post variable?

Mike.

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

No comments: