Jump to content

How to remove a line break?


spires

Recommended Posts

Hi guys,

 

I have this tool that i'm building, it's basically a big form.

What i've added is a feature that allows me to insert values from another field.

 

Example:

input field = include [[ext]]

Extension field = extension term 1

 

The out put for input field will echo: include extension term 1

 

This work fine, however, if root field has multiple values, then the output include a \n

after the [[ext]]

 

Can some one please help?

 

Here's the website:

http://adwordssupremacy.com/standard.php

- fill in all fields

- Generate adtext selected

- add at least 2 values in root terms and extension terms

- add [[ext]] inside the Campaign Name feild

- Generate the results.

You will see in the results output box, a \n has been added after the [[ext]]

 

 

Here is the code:

function generate_adgroup_ext_text(&$vars, &$keyword_array, &$adgroup_array)
{		
$adgroup_ext_text = ""; // init string to return

// Count
$count_row = '0';
// cycle through adgroup array and generate string
foreach ($adgroup_array as $adgroup)
{	$adgroup = trim($adgroup);


	// From
	if ($vars['checkbox_from'])
		$came_from = '&fm=' . $vars['from_value'];
	// End From

	// Tracker
	$key_id = "";
	if ($vars['checkbox_tracking_id'])
	{	if ($vars['$tracking_id_value'])
			$key_id .= "?" . $vars['tracking_id_value'] . "={KeyWord}";
		else
			$key_id = "?kw={KeyWord}";
	}
	// END Tracker


// ROOT Keyword Insertion

			if (strpos($vars['campaign_name'], '[[root]]'))
			{
			$campaign_name_insertion = str_replace('[[root]]', $adgroup, $vars['campaign_name']);
			}
			elseif (strpos($vars['campaign_name'], '[[ext]]'))
			{
			$campaign_name_insertion = str_replace('[[ext]]', $keyword_array[$count_row], $vars['campaign_name']);
			}
			else
			{
			$campaign_name_insertion = $vars['campaign_name'];
			}


$headline_insertion = str_replace('[[root]]', $adgroup, $vars['headline']);
$body1_insertion = str_replace('[[root]]', $adgroup, $vars['body1']);
$body2_insertion = str_replace('[[root]]', $adgroup, $vars['body2']);
$display_url_insertion = str_replace('[[root]]', $adgroup, $vars['display_url']);
$destination_url_insertion = str_replace('[[root]]', $adgroup, $vars['destination_url']);
// End Keyword Insertion

	if ($vars['adgroup_ext'])
	{	if ($vars['adgroup_ext_placement'] == 'EXT_before')
			$adgroup_ext_text .= $campaign_name_insertion . ", " . $vars['adgroup_ext'] . " $adgroup, ";
		else
			$adgroup_ext_text .= $campaign_name_insertion . ", $adgroup " . $vars['adgroup_ext'] . ", ";

		$adgroup_ext_text .= $vars['headline'] . ", " . $vars['body1'] . ", " . $vars['body2'] . ", " . $vars['display_url'] . ", " . $vars['destination_url'] . "$key_id$came_from\n";
	}
	else
	{	$adgroup_ext_text .= $campaign_name_insertion . ", $adgroup, " . $vars['headline'] . ", " . $vars['body1'] . ", " . $vars['body2'] . ", " . $vars['display_url'] . ", " . $vars['destination_url'] . "$key_id$came_from\n";
	}

$count_row += 1;
}

return $adgroup_ext_text; // return completed results string
}

 

 

Thanks for your help :)

 

Link to comment
https://forums.phpfreaks.com/topic/137112-how-to-remove-a-line-break/
Share on other sites

Hi

 

I've added:

$key_trim = trim($keyword_array[$count_row], "\n");

but it's still not doing nothing.

 

 

 

Are you sure it is only a "\n" and not a "\r\n" or vice versa?

 

$key_trim = trim($keyword_array[$count_row], "\r\n");

 

I think that would/should work if that is the case.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.