Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Function Trouble

Guest
Feb 16, 2010 Feb 16, 2010

In attempting to parse through my websites contents and extract any information between the <p> tags – I found this function that I have been trying to make work.

I am only getting it to return empty or return ‘Array’ – I have tried numerous things and just can’t seem to get it to work.

Any ideas of what I am missing?

Code Atteched:

TOPICS
Server side applications
460
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 17, 2010 Feb 17, 2010

You're not doing much to help others help you. First, you use a really vague subject line. Next, you say you're trying to get "this function" to work. And then you wrap the code in an attachment that you expect others to download, unzip, and examine.

Yes, I went to the trouble of doing all that, but I don't have the faintest idea what type of text you're passing to the function.

What I can tell you, though, is that if you're getting Array as the result, you can examine the contents of the array by using print_r() to display it.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 17, 2010 Feb 17, 2010

Oh, and another thing. Posting an identical question with a different subject line isn't going to win you many friends either. I have just deleted your duplicate post.

Sorry if this sounds a bit harsh. I know how frustrating it can be if you're struggling with an issue you can't solve, but it's also frustrating trying to help others when they make you run round in circles.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Feb 17, 2010 Feb 17, 2010

Thanks for your time and effort - I will keep trying new things until I get it to work.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Feb 17, 2010 Feb 17, 2010

You Wrote:

You're not doing much to help others help you. First, you use a really vague subject line. Next, you say you're trying to get "this function" to work. And then you wrap the code in an attachment that you expect others to download, unzip, and examine.

Sorry, just did not know what to call it.  I had no intention of wrapping the attachment as I thought I only copied it to notepad then uploaded it as a text file.  Don’t understand how it got wrapped or what wrapped it.

You Wrote:

Yes, I went to the trouble of doing all that, but I don't have the faintest idea what type of text you're passing to the function.

Thanks for trying.

You Wrote:

What I can tell you, though, is that if you're getting Array as the result, you can examine the contents of the array by using print_r() to display it.

I have printed the content – the content prints OK – I just can’t get the function to find the first <p> tag and extract the text.

You Wrote:

Oh, and another thing. Posting an identical question with a different subject line isn't going to win you many friends either. I have just deleted your duplicate post.

Sorry if this sounds a bit harsh. I know how frustrating it can be if you're struggling with an issue you can't solve, but it's also frustrating trying to help others when they make you run round in circles.

Sorry – but my original post got shoved down.  I had this happen before and never received any reply.  Was never my intention.  I am just trying to teach myself how to code.  It has been a struggle but fun in the learning.  I try very hard to research ways to fix my own code – but, when I run out of ideas to try or have tried everything I can think of, I come here.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 18, 2010 Feb 18, 2010
LATEST

brywilson88 wrote:

I have printed the content – the content prints OK – I just can’t get the function to find the first <p> tag and extract the text.

What is it that you're trying to do? If you want the text from the first paragraph in a string that contains HTML, this should do it:

preg_match('/<p>([\w\W]+?)<\/p>/i', $text_to_search, $m);

$first_para = strip_tags($m[1]);

Sorry – but my original post got shoved down.  I had this happen before and never received any reply. 

If you don't get an answer to a question, post a follow-up in the same thread saying that you still haven't solved the problem. That will move it back up the list.

Unfortunately, there aren't many people active in answering questions in this forum. I have started writing a new book, so won't be able to devote as much time here as I have in recent months.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines