|
-
Jun 20th, 2003, 09:29 AM
#1
Thread Starter
Conquistador
Possibly a preg question, splitting...
-
Jun 20th, 2003, 12:13 PM
#2
Stuck in the 80s
Right off hand, I'm not sure. But before I try a few things, can I ask what you're trying to do? Ie, is the array the only option.
If so, I'll try a few things.
-
Jun 24th, 2003, 12:25 PM
#3
Lively Member
function replace_img($text) {
$text = preg_replace("!\[img\](.*?)\[/img\]!Usi", "<img src=\\1>", $text);
return $text ;
}
and
echo replace_img($text);
-
Jun 24th, 2003, 01:15 PM
#4
Frenzied Member
-
Jun 24th, 2003, 02:24 PM
#5
Stuck in the 80s
You guys are answer the wrong question...
bekkel - Where is the array in your code? He wanted it put in an array.
phpman - I didn't check your links, so maybe you are answering it correctly.
-
Jun 24th, 2003, 04:29 PM
#6
Frenzied Member
yeah one of those is the famous Prokhaled thread, 
jsut doing preg_match() will put it in an array, so bekkel was close just needs to change is replace
-
Jun 28th, 2003, 10:51 AM
#7
Thread Starter
Conquistador
I couldn't get bekkel's thing to work properly, this is what I did the other day:
PHP Code:
$images = spliti("\[img\]", $user["signature"]);
foreach ($images as $image) { // loop through the array - if they have multiple images
if (stristr($image, "[/img]"))
{
$image = eregi_replace("\[/img\]", "", $image); // Strip out the [/img]
// Affect the image here
}
}
Basically it's a signature size checker
-
Jun 29th, 2003, 01:35 AM
#8
Frenzied Member
you said you wanted it in an array??
if(preg_match('/\[(img)\].*([:&()+]).*\[/U', $text, $match)){
echo "found something = ". $match[2];
}else{
echo "didn't find anything";
}
that will put whatever is in between the [img] tags into $match[2]
allyou had to do was read those threads I posted.
-
Jun 29th, 2003, 10:34 PM
#9
Thread Starter
Conquistador
if you'd just read what i wanted, you'd know that i wanted every image tag into consecutive array placeholders
PHP Code:
$text = "hi [img]http://www.wang.com/[/img] yo :D [img]http://www.yo.com/[/img]";
if(preg_match('/\[(img)\].*([:&()+]).*\[/U', $text, $match)){
print_r($match);
}else{
echo "didn't find anything";
}
gave me: Array ( [0] => [img]http://www.wang.com/[ [1] => img [2] => : )
my example above gives me:
Array ( [0] => http://www.wang.com/ [1] => http://www.yo.com/ )
-
Jun 30th, 2003, 08:29 AM
#10
Frenzied Member
well excuse me, just a little bit of changing and it would do what you wanted. I just grabbed that code from old code I had. didn't test it, but it will do what you wanted.
-
Jun 30th, 2003, 11:24 AM
#11
Thread Starter
Conquistador
sorry if i seem a little short and terse
i've just finished exams so i'm a little stressed and tired :P
sorry
-
Jun 30th, 2003, 08:35 PM
#12
Frenzied Member
this works
Code:
$text = "[img ]http://www.microsoft.com/me.gif[/img]";
if(preg_match('/\[img]([^\"]*)\[\/img\]/siU', $text, $match )){
echo "found something = ". $match[1];
}else{
echo "didn't find anything";
}
Last edited by phpman; Jun 30th, 2003 at 08:46 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|