In the function below, read SRC, how can I read the title in the
function get_pic_list ($content = ")
{
$pattern = "//";
Preg_match_all ($pattern, $content, $match);
$arr _pic = Array ();
$i = 0;
foreach ($match [1] as $IMGSRC)
{
$arr _pic[$i [' src '] = $imgsrc;
$i + +;
}
return $arr _pic;
}
Reply to discussion (solution)
See if it does.
function get_pic_list ($content = ") { $pattern ="//"; Preg_match_all ($pattern, $content, $match); $arr _pic = Array (); $i = 0; For ($i =0, $len =count ($match [1]), $i < $len, $i + +) { $arr _pic[$i] [' src '] = $match [1][$i]; $arr _pic[$i [' title '] = $match [2][$i]; } return $arr _pic;} $content =<<
<>
admin menu txt; $result = get_pic_list ($content);p rint_r ($result);
Array ( [0] = = Array ( [src] =/assets/ico_set.gif [title] = Title1 ) [1] = > Array ( [src] =/assets/arrow_down.gif [title] = Title2 ))
After the call, the display is not correct, I originally uploaded a lot of pictures, but only show two, and show these two I use to view the source, the title value is empty.
In the following call page JS is not also to make changes?? How to change??
{foreach from= $album _list item=pic}
{/foreach}
Do you have a title tag for each picture? And the title is placed behind Src.
may not be the case of JS, because I deleted that section of JS, but also only show two pictures without the title value
Not every title, some have, some not
Add title to try. No, plus title= ""
Just added, also only show a part, I tried, respectively, the value of the title is set to 1,2,3,4,5,6,7,8, but only show the 2,4,6,8
is to show a single
If you are unsure whether each picture has a title tag, two regular fetches are required.
Modify the following:
function get_pic_list ($content = ") { $pattern ="//"; Preg_match_all ($pattern, $content, $match); $arr _pic = Array (); $i = 0; For ($i =0, $len =count ($match [1]), $i < $len, $i + +) { $arr _pic[$i] [' src '] = $match [1][$i]; Preg_match ('/title=[\ ' |\ "] (. *?) [\ ' |\ ']/', $match [0][$i], $match 1); $arr _pic[$i [' title '] = Isset ($match 1[1])? $match 1[1]: '; } return $arr _pic;} $content =<<
<>
admin menu TXT; $result = Get_pic_list ($content);p rint_r ($result);
Array ( [0] = = Array ( [src] =/assets/ico_set.gif [title] = Title1 ) [1] = > Array ( [src] =/assets/arrow_down.gif [title] = Title2 ) [2] = = Array ( [src] =/assets/arrow_down123.gif [title] =) )
If you still have a problem, you can send $content out to see.
Yes, thank you.