I cant't able to explode this string

$str = "1.71 – Carat Cushion Cut Diamond ";
 $result = explode("–",$str);

and the result is?

1 Like
Array ( [0] => 1.71 [1] => Carat Cushion Cut Diamond )

But this output not come , I can’t able separate –.

I just tried your code and it works fine?

	ini_set('display_errors', 'true');

	echo '$str: ',
		$str = '1.71 – Carat Cushion Cut Diamond ';

	$result = explode("–", $str);
	echo '<pre>$result: ';
		print_r ( $result );
		# var_dump( $result );
	echo '</pre>';



The code did exactly that.

It separated the String into an array containing two component Strings.

What are you wanting as a result if not that?

1 Like

$all_product_name = explode(“#8211;”,$str );

Hi Team,
This code working fine because - is a special character ,so i use html special code.

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.