Jump to content
php.lv forumi

get_file_contents


anonīms

Recommended Posts

Ceru, ka f-ju sauca tā. Apskatījos manuāli, bet īsti nedalaca.

Piemēram ir kods no citas lapas source

<h3 style='font-size:20px'>te iet teksts</h3>

Kā es varētu iegūt to, kas ir iekšs tā h3.(Šajā gadījumā "te iet teksts")? Ideja ir izvlikt no viena foruma nikus pēc get ID.

Link to comment
Share on other sites

čota nerabotaet.

		function getString($str, $start, $end)
{
$str_low = strtolower($str);
$pos_start = strpos($str_low, $start);
$pos_end = strpos($str_low, $end, ($pos_start + strlen($start)));
if ( ($pos_start !== false) && ($pos_end !== false) )
{
$pos1 = $pos_start + strlen($start);
$pos2 = $pos_end - $pos1;
return substr($str, $pos1, $pos2);
}
}
$html_content = file_get_contents("http://php.lv/f");
//echo $html_content;
$match = getString($html_contents, '<title>', '</title>');

echo $match;

Warning: strpos() [function.strpos]: Offset not contained in string in
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...