cut the content of another page?

Discussion in 'PHP' started by hoangthienphuc, Aug 11, 2007.

  1. hoangthienphuc

    hoangthienphuc New Member

    Joined:
    Mar 15, 2007
    Messages:
    17
    Likes Received:
    0
    Trophy Points:
    0
    I used file_get_content() function to get the content of another page, then use substr function cut the content i need and echo it in my page. But i wonder if that page have change the content( by query data in database ) and my content substr from that page will be not correct and my page layout will break! How can i use another function instead of substr function?? :confused:
     
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    If you use some other function then also it will break because you should be having the provision for the changes that may happen at the source or what you could do it have the content and instead of displaying it directly you could insert into the database.
     
  3. hoangthienphuc

    hoangthienphuc New Member

    Joined:
    Mar 15, 2007
    Messages:
    17
    Likes Received:
    0
    Trophy Points:
    0
    Oh! That's a good ideas! But when it's change the content and i must modify in my database, i think it's not so good! Have some other solution for my solution?
    Thanks for your reading! :D
     
  4. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    If you are not sure of the source you cannot have any algo.
     
  5. hoangthienphuc

    hoangthienphuc New Member

    Joined:
    Mar 15, 2007
    Messages:
    17
    Likes Received:
    0
    Trophy Points:
    0
    Can i post my code in here? Please help for my problem
     
  6. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    You can but have the code blocks in the posts for the code.
     
  7. hoangthienphuc

    hoangthienphuc New Member

    Joined:
    Mar 15, 2007
    Messages:
    17
    Likes Received:
    0
    Trophy Points:
    0
    Yes! and this is my code :
    Code:
    $str1 = file_get_contents("an example page");  		$image = substr($str1, 10423, 120);
    then, i echo $image that got "<img src="url"/>" from that page and want it's always stand like that whenever that page change the content.
     
  8. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    You need to design a better algo rather than just to use the API for it.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice