Jump to content

Recommended Posts

Hey guys,

I have some code in which I am trying to find [ code ]*[ / code ], explode the entire string into the segments, and return a flag for the matched part.

 

Turn this: Some random content. [ code ]run main;[ / code ] That was the main program.[ code ]include 'random.php';[ / code ]

into this: [0]Some random content. [1]run main; [2] That was the main program. [3]include 'random.php'

With flags: [0]1 [1]3

So what's the code, and what's wrong with it that you're not getting the desired results?

 

What I have uses preg_match_all. It runs the code first then outputs the rest. I can't seem to figure out how to do it the other way.

function parseInlineCode($string = NULL, $body = false)
{
	$regex = "/\[code\](.+)\[\/code\]/i";
	preg_match_all($regex, $string, $code);
	print_r($code);
	/*eval('?>' . $code[1][0] . '<?php');*/
	$code  = explode(";", $code[2]);

	for($i = 0; $i < count($code); $i++) {
		$this->runCode($code[$i], $body);
	}
}

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.   Restore formatting

  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.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.