Link to home
Start Free TrialLog in
Avatar of hiddenpearls
hiddenpearlsFlag for Pakistan

asked on

php explode alternative in jquery

hi . i have a value in variable  like this price_33,product_1 . i want to explode like php function and store in array or two separate variables ..

simple javascript or jquery solution ?
ASKER CERTIFIED SOLUTION
Avatar of David S.
David S.
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of hiddenpearls

ASKER

thanks , it helped me !
hmm one problem .. still

$copy_image_product_price_id=$($id).attr("id");
                 
                              var exploded = copy_image_product_price_id.split(',');
                              var product_code=exploded[0];
                              var product_price=exploded[1];

i m getting id and then split it but it not works ..giving me error ..  
"$copy_image_product_price_id" and "copy_image_product_price_id" are two different variable names. Make sure they match.
@Kravimir: yes , that was the problem . u right . but what is difference between them ?
are they same variables of javascript ?
 
In PHP "$" indicates the start of a variable name, but in JavaScript it's just one of the characters allowed in variable names.  "myString" and "$myString" are different variable names just like "myString", "mystring", and "my_string" are all different.

I suggest you read this: https://developer.mozilla.org/en/Core_JavaScript_1.5_Guide/Variables